19

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.

3

You should check out WinSplit Revolution; it has what you need and is customizable.

alt text

| improve this answer | |
  • Looks like with 3 clicks of the middle button in WinSplit's window causes my focused window to stretch and fill the whole height of the monitor, which is fine, and be centered horizontally. :) – Sarah Vessels Jul 2 '10 at 13:26
14

This is not exactly for centering, but lets you move the window left and right (and up and down) easily.

  1. Focus a window.
  2. Press Alt+Space.
  3. Press M (for “Move”).
  4. Use the arrow keys to move the window exactly where you want it.
  5. Press Enter when done.
| improve this answer | |
  • 1
    This solution requires no additional software to be installed. It might not be the exact solution, but I think it is enough to get the job done – afuzzyllama Jun 30 '17 at 2:43
  • This only works if a window is not maximized. – TylerH Feb 27 '18 at 21:05
  • @TylerH: that is true. However, it only requires you to press windows + right (to place window in 50% right position), and then follow the instructions in this answer to move it the left. – Rasmus Larsen Sep 28 '18 at 7:44
13

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.
| improve this answer | |
  • 2
    That didn't seem to do it for me. It looks like it minimizes my window, or restores it if the window is maximized. – Sarah Vessels Jun 24 '10 at 20:00
  • 2
    On my machine, dual monitor, I can click Win-Left and it will go to left 50% on that screen. If I continue clicking on Win-Left it will go to right 50% on the other screen, next will center and finally left on the other screen. Win-Right does the opposite – wbeard52 Jun 24 '10 at 20:21
  • 1
    Win-Down is plain wrong. It either restores a window from maximized or minimizes it (if it's restored already). It won't do anything center-y with the window. – Joey Jun 24 '10 at 22:37
  • 3
    @wbeard52: I just tried Win-Left repeatedly and it cycled through 50% on left side of screen, 50% on right side of screen, and how my window originally was (not centered, small). – Sarah Vessels Jul 2 '10 at 13:22
  • 2
    Repeatedly pressing Win-Left or Win-Right simply cycles through placing the window on the left/right 50% of the available monitors, then puts it back where it was before. It does not center the window in any way. – dgw May 14 '15 at 6:18
5

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.

| improve this answer | |
  • 1
    Almost great... Except for the one serious issue. With multiple extended monitors, this always moves a window from a secondary monitor to the main one. Any ideas on how to fix this? WinMove does not seem to have any extra parameters. – DKroot Aug 27 '19 at 3:46
  • @DKroot I'll have to try with a second screen. I've only been using this on a single ultrawide. Here's what the doc says on WinMove: «Negative values are allowed for the x and y coordinates to support multi-monitor systems and to allow a window to be moved entirely off screen.» There are examples of multi-monitor scripts on the forum, but it gets more complicated: autohotkey.com/board/topic/… – vctls Aug 27 '19 at 19:52
  • Thanks so much for the link! I was able to combine your script and the linked script into one working perfectly. (The linked script does not resize hence not working e.g. on maximized windows). The script is too long to be included in the comments. Do you mind me posting it as a separate answer? – DKroot Aug 28 '19 at 20:25
  • Another testing note on your script: interestingly, in a setup with 3 monitors, e.g. #1 main, #2 and #3 it works fine on #1 and #3, but moves windows from #2 to #1. – DKroot Aug 28 '19 at 20:28
  • 1
    Huh, that's weird. I updated it to make it work on multiple monitors. I tried to keep it as short and on topic as possible, but you might want to go for the Deluxe Edition like the ones in the forum ;) – vctls Aug 29 '19 at 11:53
2

Try Sizer by Brian apps. It's free and completely customisable. http://www.brianapps.net/sizer.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.