Returns the control names for all controls in the specified window.

Controls := WinGetControls(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 control names for all controls in the specified window. Each name of a control consists of its class name followed immediately by its sequence number (ClassNN), as shown by Window Spy. 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 name of the first control, Controls[2] contains the name 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 if the window supports tabbing.

Error Handling

A TargetError is thrown if the window could not be found.


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.

WinGetControlsHwnd, Win functions, Control functions


Extracts the individual control names from the active window's control list.

for n, ctrl in WinGetControls("A")
    Result := MsgBox("Control #" n " is '" ctrl "'. Continue?",, 4)
    if (Result = "No")

Displays in real time the active window's control list.

SetTimer WatchActiveWindow, 200

        Controls := WinGetControls("A")
        ControlList := ""
        for ClassNN in Controls
            ControlList .= ClassNN . "`n"
        if (ControlList = "")
            ToolTip "The active window has no controls."
            ToolTip ControlList
    catch TargetError
        ToolTip "No visible window is active."