Function Reference


Retrieves the position and size of a given window.

WinGetPos ( "title" [, "text"] )


title The title/hWnd/class of the window to get the position/size. See Title special definition.
text [optional] The text of the window to get the position/size. Default is an empty string. See Text special definition.

Return Value

Success: a 4-element array containing the following information:
    $aArray[0] = X position
    $aArray[1] = Y position
    $aArray[2] = Width
    $aArray[3] = Height
Failure: sets the @error flag to non-zero if the window is not found.


WinGetPos() returns negative numbers such as -32000 for minimized windows, but works fine with (non-minimized) hidden windows.
If the window title "Program Manager" is used, the function will return the size of the desktop. If multiple windows match the criteria, the most recently active window is used.


WinGetClientSize, WinGetState, WinMove


#include <MsgBoxConstants.au3>


Func Example()
        ; Retrieve the position as well as height and width of the active window.
        Local $aPos = WinGetPos("[ACTIVE]")

        ; Display the array values returned by WinGetPos.
        MsgBox($MB_SYSTEMMODAL, "", "X-Pos: " & $aPos[0] & @CRLF & _
                        "Y-Pos: " & $aPos[1] & @CRLF & _
                        "Width: " & $aPos[2] & @CRLF & _
                        "Height: " & $aPos[3])
EndFunc   ;==>Example