WinMove

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

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

Parameters

X, Y

Type: Integer

The X and Y coordinates (in pixels) of the upper left corner of the target window's new location. The upper-left pixel of the screen is at 0, 0.

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

Otherwise, X and/or Y can be omitted, in which case the current position is used.

Width, Height

Type: Integer

The new width and height of the window (in pixels). If either is omitted or blank, the size in that dimension will not be changed.

WinTitle

Type: String, Integer or Object

A window title or other criteria identifying the target window. See WinTitle.

WinText

Type: String

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.

ExcludeTitle

Type: String

Windows whose titles include this value will not be considered.

ExcludeText

Type: String

Windows whose text include this value will not be considered.

Error Handling

An exception is thrown if the window could not be found or the change could not be applied.

Remarks

If Width and Height are 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 and Height are large, most windows will go no larger than approximately 12 pixels beyond the dimensions of the desktop.

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.

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

The speed of WinMove is affected by SetWinDelay.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.

Related

ControlMove, WinGetPos, WinHide, WinMinimize, WinMaximize, Win functions

Examples

#1

Run "calc.exe"
WinWaitActive "Calculator"
WinMove 0, 0 ; Move the window found by WinWait to the upper-left corner of the screen.

#2

MyGui := Gui.New("ToolWindow -Sysmenu Disabled", "The clipboard contains:")
MyGui.Add("Text",, A_Clipboard)
MyGui.Show("w400 h300")
WinMove 0, 0,,, MyGui.Title ; Move the splash window to the top left corner.
MsgBox "Press OK to dismiss the MyGui window"
MyGui.Destroy

#3: The following function centers the specified window on the screen:

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