WinMove

Changes the position and/or size of the specified window.

WinMove , X, Y
WinMove , WinTitle, WinText, X, Y, Width, Height, ExcludeTitle, ExcludeText

Parameters

X, Y

If either is blank or omitted, the position in that dimension will not be changed. Otherwise, specify the X and Y coordinates (in pixels) of the upper left corner of the target window's new location, which can be expressions. The upper-left pixel of the screen is at 0, 0.

If these are the only parameters given with the command, the Last Found Window will be used as the target window.

WinTitle, WinText, ExcludeTitle, ExcludeText

If each of these is blank or omitted, the Last Found Window will be used. Otherwise, specify for WinTitle a window title or other criteria to identify the target window and/or for WinText a substring from a single text element of the target window (as revealed by the included Window Spy utility).

ExcludeTitle and ExcludeText can be used to exclude one or more windows by their title or text. Their specification is similar to WinTitle and WinText, except that ExcludeTitle does not recognize any criteria other than the window title.

Window titles and text are case-sensitive. By default, hidden windows are not detected and hidden text elements are detected, unless changed with DetectHiddenWindows and DetectHiddenText. By default, a window title must start with the specified WinTitle or ExcludeTitle to be a match, unless changed with SetTitleMatchMode.

See also the known limitation below.

Width, Height

If either is blank, omitted, or the word DEFAULT, the size in that dimension will not be changed. Otherwise, specify the new width and height of the window (in pixels), which can be expressions.

Remarks

If Width or Height is small (or negative), most windows with a title bar will generally go no smaller than 112 x 27 pixels (however, some types of windows may have a different minimum size). If Width or Height is large, most windows will go no larger than approximately 12 pixels beyond the dimensions of the desktop.

Negative X and Y coordinates are allowed to support multi-monitor systems and to move a window entirely off-screen.

Although WinMove cannot move minimized windows, it can move hidden windows if DetectHiddenWindows is on.

The speed of WinMove is affected by SetWinDelay.

Known limitation: If WinTitle or WinText contains (, [ or {, but not the closing counterpart, such as WinMove KEDIT - [, the parameter is automatically interpreted as an expression, resulting in an error message. To prevent this, use the percent-space prefix to force an expression, such as WinMove % "KEDIT - [".

On systems with multiple screens which have different DPI settings, the final position and size of the window may differ from the requested values due to OS DPI scaling.

ControlMove, WinGetPos, WinHide, WinMinimize, WinMaximize, WinSet

Examples

Opens the calculator, waits until it exists and moves it to the upper-left corner of the screen.

Run, calc.exe
WinWait, Calculator
WinMove, 0, 0 ; Use the window found by WinWait.

Creates a fixed-size popup window that shows the contents of the clipboard and moves it to the upper-left corner of the screen.

SplashTextOn, 400, 300, Clipboard, The clipboard contains:`n%Clipboard%
WinMove, Clipboard,, 0, 0
MsgBox, Press OK to dismiss the SplashText
SplashTextOff

Centers a window on the screen.

CenterWindow("ahk_class Notepad")

CenterWindow(WinTitle)
{
    WinGetPos,,, Width, Height, %WinTitle%
    WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}