Function Reference


Moves and/or resizes a window.

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )


title The title/hWnd/class of the window to move/resize. See Title special definition.
text The text of the window to move/resize. See Text special definition.
x X coordinate to move to.
y Y coordinate to move to.
width [optional] New width of the window.
height [optional] New height of the window.
speed [optional] the speed to move the windows in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous.

Return Value

Success: a handle to the window.
Failure: 0 if the window is not found.


WinMove() has no effect on minimized windows, but WinMove() works on hidden windows.
If the width and height are small (or negative), the window will go no smaller than 112 x 27 pixels. If width and height are large, the window will go no larger than approximately [12+@DesktopWidth] x [12+@DesktopHeight] pixels.
Negative values are allowed for the x and y coordinates. In fact, you can move a window off screen; and if the window's program is one that remembers its last window position, the window will appear in the corner (but fully on-screen) the next time you launch the program.
If multiple windows match the criteria, the most recently active window is used.

If x and y equal to the Default keyword no move occurs, just resizing.

When speed is used the move is done with the new size.


WinActivate, WinClose, WinGetClientSize, WinGetPos, WinSetState



Func Example()
        ; Run Notepad

        ; Wait 10 seconds for the Notepad window to appear.
        Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

        ; Retrieve the position as well as the height and width of the Notepad window. We will use this when we have to move the window back to the original position.
        Local $aPos = WinGetPos($hWnd)

        ; Move the Notepad to the x, y position of 0, 0 and set the height and width at 200, 200.
        WinMove($hWnd, "", 0, 0, 200, 200)

        ; Wait for 2 seconds to display the new position of the Notepad window.

        ; Move the Notepad window back to the original position by using the array returned by WinGetPos.
        WinMove($hWnd, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])

        ; Wait for 2 seconds to display the original position of the Notepad window.

        ; Close the Notepad window using the handle returned by WinWait.
EndFunc   ;==>Example