I find Win-left arrow and Win-right arrow really useful in Windows 7 to make a window take up 50% of the left or right side of the screen, respectively. However, is there any command that will make a window take up 50% of the screen and be centered? Even if it doesn't adjust the size of the window, is there a keyboard shortcut to make a window center itself vertically and horizontally? Thanks.
6 Answers
You should check out WinSplit Revolution; it has what you need and is customizable.
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.
Try Sizer by Brian apps. It's free and completely customisable.
I took @vctls solution and made it so the windows+up key would perform this function and maximise/restore the window. If the window is maximised it will restore it to the middle of the screen. If the window is restored it will maximise it. A second press will centre it active. Basically I combined this case and this one. It means you get all the functionality if windows+up with the added bonus of centreAutohotkey script to toggle minimize/restore?
It also fixes the fact that changing the width ( Change the factor here to your desired width) centres the window still
#Up::CenterActiveWindow() ; if win+↑ is pressed
CenterActiveWindow()
{
; Get the window handle from de active window.
winHandle := WinExist("A")
WinGet MX, MinMax, A
If MX { WinRestore A
}
Else { WinMaximize A return
}
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.6 ; Change the factor here to your desired width.
winH := A_Bottom
winX := ((A_Right - A_Left) - winW) /2
winY := A_Top
WinMove, A,, winX, winY, winW, winH
}