keyboard shortcut in Windows 7 to center window
This is not exactly for centering, but lets you move the window left and right (and up and down) easily.
- Focus a window.
- Press Alt+Space.
- Press M (for “Move”).
- Use the arrow keys to move the window exactly where you want it.
- Press Enter when done.
The Windows+arrow keys are quite useful here.
- (Windows)+← (Left) and +→ (Right) cycle through going to the left or right 50% of the screen, and restoring the window to its original size and position.
- +↑ (Up) maximizes the window.
- +↓ (Down) restores the window if it is maximized, and minimizes it otherwise.
I would suggest using AutoHotkey.
An example script that does exactly what you asked was already provided in an answer to another question.
Here's the code of the script:
#!Up::CenterActiveWindow() ; if win+alt+↑ is pressed
CenterActiveWindow()
{
; Get the window handle from de active window.
winHandle := WinExist("A")
VarSetCapacity(monitorInfo, 40)
NumPut(40, monitorInfo)
; Get the current monitor from the active window handle.
monitorHandle := DllCall("MonitorFromWindow", "uint", winHandle, "uint", 0x2)
DllCall("GetMonitorInfo", "uint", monitorHandle, "uint", &monitorInfo)
; Get WorkArea bounding coordinates of the current monitor.
A_Left := NumGet(monitorInfo, 20, "Int")
A_Top := NumGet(monitorInfo, 24, "Int")
A_Right := NumGet(monitorInfo, 28, "Int")
A_Bottom := NumGet(monitorInfo, 32, "Int")
; Calculate window coordinates.
winW := (A_Right - A_Left) * 0.5 ; Change the factor here to your desired width.
winH := A_Bottom
winX := A_Left + (winW / 2)
winY := A_Top
WinMove, A,, winX, winY, winW, winH
}
I made a slight adjustment so the bottom of the window doesn't go beneath the taskbar, and changed the windowWidth
from 0.7 to 0.5.
Edit: now working with multiple monitors, and uses the work area for top and bottom values.
On a side note, WinSplit Revolution has been discontinued and replaced by a paid app called MaxTo.
In addition to being very powerful and covering much more use cases, AutoHotkey is also free and open source.