Returns the unique ID numbers of all existing windows that match the specified criteria.

List := WinGetList(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) of all existing windows that match the specified parameters. If there is no matching window, an empty array is returned.

For example, if the return value is assigned to a variable named List and two matching windows are discovered, List[1] contains the ID of the first window, List[2] contains the ID of the second window, and List.Length returns the number 2.

Windows are retrieved in order from topmost to bottommost (according to how they are stacked on the desktop).


To retrieve all windows on the entire system, omit all four title/text parameters.

The ID of the window 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.


WinGetCount, Win functions, Control functions


#1: This will visit all windows on the entire system and display info about each of them:

ids := WinGetList(,, "Program Manager")
for this_id in ids
    WinActivate this_id
    this_class := WinGetClass(this_id)
    this_title := WinGetTitle(this_id)
    Result := MsgBox(
        "Visiting All Windows
        " A_Index " of " ids.Length "
        ahk_id " this_id "
        ahk_class " this_class "
        " this_title "

    ),, 4)
    if (Result = "No")