Function Reference


ControlGetPos

Retrieves the position and size of a control relative to its window.

ControlGetPos ( "title", "text", controlID )

Parameters

title The title/hWnd/class of the window to access. See Title special definition.
text The text of the window to access. See Text special definition.
controlID The control to interact with. See Controls.

Return Value

Success: an array containing the size and the control's position relative to its client window:
    $aArray[0] = X position
    $aArray[1] = Y position
    $aArray[2] = Width
    $aArray[3] = Height
Failure: sets the @error flag to 1.

Remarks

The title/text is referencing the parent window, so be careful with "", which references the active window which may not be the one containing the controlID control.

Related

ControlCommand, ControlMove

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

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

    ; Retrieve the position x, y and size (width and height) of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetPos.
    Local $aPos = ControlGetPos($hWnd, "", "Edit1")

    ; Display the position and size of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example