Ventanas de centrado

Si a usted, como a mí, le encanta el orden en el escritorio y mientras trabaja, colocar la ventana de la aplicación en el centro de la pantalla es una idea y una práctica muy interesantes.

Abres una ventana, luego otra, y así sucesivamente, de modo que se crea una variedad de ventanas en el escritorio. Y, de acuerdo, qué bonito es cuando la ventana que necesitas, en la que estás trabajando ahora, está exactamente en el medio: en el centro de la pantalla.

He encontrado una aplicación que funciona de forma colapsada: Window Centering Helper. La aplicación tiene una versión portátil, que es más que suficiente para una tarea tan simple.


WindowCenteringHelper-PE

El programa dispone de una serie de ajustes que determinan el centrado automático y manual de las ventanas. Por ejemplo, puede pulsar la tecla "Mayúsculas" derecha tres veces en el teclado y la ventana activa se centrará.

Descargar Window Centering Helper

  • Nombre del archivo: WindowCenteringHelper-PE.exe (enlace directo)
  • Versión: 1.2.11 beta
  • Tamaño del archivo: 1,3 MByte
  • Requisito: Sistema operativo Windows 7/8.1/10/11
  • MD5: a730d2d86ded709c737c3a45204fe549

Hay un "PERO" importante. El programa no ha sido actualizado desde hace mucho tiempo, tiene una interfaz de usuario sólo en Inglés (tal vez es importante para alguien) y no tiene posibilidad de trabajar en modo totalmente oculto.

Guión de alineación

He encontrado otra solución para mí - un script escrito por mí mismo. Funciona de forma totalmente automática y no se muestra en el sistema en absoluto (sin iconos de la bandeja del sistema).


' Silent Window Centerer Launcher (Final Version)
' Автор: Илья Анисимов
' Web: https://iluh.in
' Запускает центрирование окон с исправленной логикой

Set objShell = CreateObject("WScript.Shell")

' Проверяем, запущен ли уже процесс
Set objWMI = GetObject("winmgmts:")
Set colProcesses = objWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'powershell.exe' AND CommandLine LIKE '%WindowCentererSilent%'")

If colProcesses.Count > 0 Then
    WScript.Quit
End If

' PowerShell команда с исправленной переменной
psCommand = "powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -Command """ & _
"$Host.UI.RawUI.WindowTitle = 'WindowCentererSilent'; " & _
"Add-Type -AssemblyName System.Windows.Forms; " & _
"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; " & _
"public class Win32 { " & _
"[DllImport(\""user32.dll\"")] public static extern IntPtr GetForegroundWindow(); " & _
"[DllImport(\""user32.dll\"")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); " & _
"[DllImport(\""user32.dll\"")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); " & _
"[DllImport(\""user32.dll\"")] public static extern bool IsWindowVisible(IntPtr hWnd); " & _
"[DllImport(\""user32.dll\"")] public static extern bool IsZoomed(IntPtr hWnd); " & _
"[DllImport(\""user32.dll\"")] public static extern bool IsIconic(IntPtr hWnd); " & _
"[DllImport(\""user32.dll\"")] public static extern IntPtr GetParent(IntPtr hWnd); " & _
"[DllImport(\""dwmapi.dll\"")] public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out bool pvAttribute, int cbAttribute); " & _
"[DllImport(\""user32.dll\"")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); " & _
"[StructLayout(LayoutKind.Sequential)] public struct RECT { public int Left; public int Top; public int Right; public int Bottom; } " & _
"public const uint SWP_NOSIZE = 0x0001; public const uint SWP_NOZORDER = 0x0004; " & _
"public const int DWMWA_CLOAKED = 14; }'; " & _
"$screen = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea; " & _
"$excludeProcesses = @('ShellExperienceHost', 'SearchHost', 'StartMenuExperienceHost', 'LockApp', 'SystemSettings', 'explorer'); " & _
"function Center-Window($hWnd) { " & _
"if ($hWnd -eq [IntPtr]::Zero -or -not [Win32]::IsWindowVisible($hWnd) -or [Win32]::IsZoomed($hWnd) -or [Win32]::IsIconic($hWnd) -or [Win32]::GetParent($hWnd) -ne [IntPtr]::Zero) { return } " & _
"try { $isCloaked = $false; " & _
"[Win32]::DwmGetWindowAttribute($hWnd, [Win32]::DWMWA_CLOAKED, [ref]$isCloaked, [System.Runtime.InteropServices.Marshal]::SizeOf([bool])) | Out-Null; " & _
"if ($isCloaked) { return } } catch {} " & _
"$processId = 0; [Win32]::GetWindowThreadProcessId($hWnd, [ref]$processId) | Out-Null; if ($processId -eq 0) { return } " & _
"try { $processName = (Get-Process -Id $processId -ErrorAction Stop).ProcessName; if ($excludeProcesses -contains $processName) { return } } catch { return } " & _
"$rect = New-Object Win32+RECT; " & _
"if (-not [Win32]::GetWindowRect($hWnd, [ref]$rect)) { return } " & _
"$width = $rect.Right - $rect.Left; $height = $rect.Bottom - $rect.Top; " & _
"if ($width -le 80 -or $height -le 40 -or $width -ge $screen.Width -or $height -ge $screen.Height) { return } " & _
"$newX = [math]::Max(0, ($screen.Width - $width) / 2 + $screen.Left); " & _
"$newY = [math]::Max(0, ($screen.Height - $height) / 2 + $screen.Top); " & _
"[Win32]::SetWindowPos($hWnd, [IntPtr]::Zero, [int]$newX, [int]$newY, 0, 0, [Win32]::SWP_NOSIZE -bor [Win32]::SWP_NOZORDER) | Out-Null; } " & _
"$lastWindow = [IntPtr]::Zero; " & _
"while ($true) { " & _
"try { " & _
"$hWnd = [Win32]::GetForegroundWindow(); " & _
"if ($hWnd -ne $lastWindow) { " & _
"$lastWindow = $hWnd; " & _
"Start-Sleep -Milliseconds 150; " & _
"Center-Window $hWnd; " & _
"} } catch { } " & _
"Start-Sleep -Milliseconds 300; }"""

' Запускаем PowerShell скрыто
objShell.Run psCommand, 0, False


Descargar el archivo de script .vbs

Puede guardar esta secuencia de comandos en un archivo *.vbs y poner ese archivo en el cargador automático:

  1. Abra la ventana Ejecutar (atajo de teclado: Ganar+R).
  2. Introduzca el comando shell:inicio.
  3. Pulse "OK" o "Enter" para ejecutar el comando.

También puede ejecutar este archivo usted mismo cuando lo necesite. Para terminar la secuencia de comandos en el Administrador de tareas, introduzca en la barra de búsqueda powershell y finalizar el proceso Windows PowerShell - "powershell.exe“.