ControlGetPos

Retrieves the position and size of a control.

ControlGetPos X, Y, Width, Height, Control, WinTitle, WinText, ExcludeTitle, ExcludeText

Parameters

X, Y

Type: Variable

The names of the variables in which to store the X and Y coordinates (in pixels) of Control's upper left corner. These coordinates are relative to the upper-left corner of the target window's client area and thus are the same as those used by ControlMove.

If either X or Y is omitted, the corresponding values will not be stored.

Width, Height

Type: Variable

The names of the variables in which to store Control's width and height (in pixels). If omitted, the corresponding values will not be stored.

Control

Type: String, Integer or Object

The control's ClassNN, text or HWND, or an object with a Hwnd property. For details, see The Control Parameter.

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 or control could not be found.

Remarks

Unlike functions that change a control, ControlGetPos does not have an automatic delay (SetControlDelay does not affect it).

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

Related

ControlMove, WinGetPos, Control functions

Examples

#1: This example will continuously update and display the name and position of the control currently under the mouse cursor:

Loop
{
    Sleep 100
    MouseGetPos ,, WhichWindow, WhichControl
    try ControlGetPos x, y, w, h, WhichControl, WhichWindow
    ToolTip WhichControl "`nX" X "`tY" Y "`nW" W "`t" H
}