Returns the unique ID numbers for all controls in the specified window.

Controls := WinGetControlsHwnd(WinTitle, WinText, ExcludeTitle, ExcludeText)



Type: String, Integer or Object

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


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.


Type: String

Windows whose titles include this value will not be considered.


Type: String

Windows whose text include this value will not be considered.

Return Value

Type: Array

This function returns an array containing the window handles (HWND) for all controls in the specified window. If there is no matching window, an empty string is returned.

For example, if the return value is assigned to a variable named Controls and two controls are present, Controls[1] contains the ID of the first control, Controls[2] contains the ID of the second control, and Controls.Length returns the number 2.

Controls are sorted according to their Z-order, which is usually the same order as the navigation order via Tab key if the window supports tabbing.

Error Handling

An exception is thrown if the window could not be found or there was an error retrieving the window handles (HWND) of its controls.


The ID of the window or control under the mouse cursor can be retrieved with MouseGetPos.

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


WinGetControls, Win functions, Control functions