Retrieves the specified window's unique ID, process ID, process name, or a list of its controls. It can also retrieve a list of all windows matching the specified criteria.
WinGet, OutputVar , SubCommand, WinTitle, WinText, ExcludeTitle, ExcludeText
For SubCommand, specify one of the following:
Retrieves the unique ID number of a window.
WinGet, OutputVar, ID , WinTitle, WinText, ExcludeTitle, ExcludeText
Also known as the window handle (HWND). If there is no matching window, OutputVar is made blank. The functions WinExist() and WinActive() can also be used to retrieve the ID of a window; for example, WinExist("A")
is a fast way to get the ID of the active window. To discover the HWND of a control (for use with Post/SendMessage or DllCall), use ControlGet Hwnd or MouseGetPos.
Retrieves the unique ID number of the last/bottommost window if there is more than one match.
WinGet, OutputVar, IDLast , WinTitle, WinText, ExcludeTitle, ExcludeText
Also known as the window handle (HWND). If there is no matching window, OutputVar is made blank. If there is only one match, it performs identically to the ID sub-command. This concept is similar to that used by WinActivateBottom.
Retrieves the Process ID number of a window.
WinGet, OutputVar, PID , WinTitle, WinText, ExcludeTitle, ExcludeText
If there is no matching window, OutputVar is made blank.
Retrieves the name of the process that owns a window.
WinGet, OutputVar, ProcessName , WinTitle, WinText, ExcludeTitle, ExcludeText
For example, this would be "notepad.exe". If there are no matching windows, OutputVar is made blank.
Retrieves the full path and name of the process that owns a window.
WinGet, OutputVar, ProcessPath , WinTitle, WinText, ExcludeTitle, ExcludeText
For example, this would be "C:\Windows\System32\notepad.exe". If there are no matching windows, OutputVar is made blank.
Retrieves the number of existing windows that match the title/text parameters.
WinGet, OutputVar, Count , WinTitle, WinText, ExcludeTitle, ExcludeText
If there are no matching windows, OutputVar is set to zero. To count all windows on the system, omit all four title/text parameters. Hidden windows are included only if DetectHiddenWindows has been turned on.
Retrieves the unique ID numbers of all existing windows that match the title/text parameters.
WinGet, OutputVar, List , WinTitle, WinText, ExcludeTitle, ExcludeText
To retrieve all windows on the entire system, omit all four title/text parameters. Each ID number is stored in a variable whose name begins with OutputVar's own name (to form a pseudo-array), while OutputVar itself is set to the number of retrieved items (0 if none). For example, if OutputVar is MyArray and two matching windows are discovered, MyArray1 will be set to the ID of the first window, MyArray2 will be set to the ID of the second window, and MyArray itself will be set to the number 2. Windows are retrieved in order from topmost to bottommost (according to how they are stacked on the desktop). Hidden windows are included only if DetectHiddenWindows has been turned on. Within a function, to create a pseudo-array that is global instead of local, declare MyArray as a global variable prior to using this command (the converse is true for assume-global functions). However, it is often also necessary to declare each variable in the set, due to a common source of confusion.
Retrieves the minimized/maximized state for a window.
WinGet, OutputVar, MinMax , WinTitle, WinText, ExcludeTitle, ExcludeText
OutputVar is made blank if no matching window exists; otherwise, it is set to one of the following numbers:
Retrieves the control name for each control in a window.
WinGet, OutputVar, ControlList , WinTitle, WinText, ExcludeTitle, ExcludeText
If no matching window exists or there are no controls in the window, OutputVar is made blank. Otherwise, each control name consists of its class name followed immediately by its sequence number (ClassNN), as shown by Window Spy.
Each item except the last is terminated by a linefeed (`n). To examine the individual control names one by one, use a parsing loop as shown in example #3 below.
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.
Retrieves the unique ID number for each control in a window.
WinGet, OutputVar, ControlListHwnd , WinTitle, WinText, ExcludeTitle, ExcludeText
If no matching window exists or there are no controls in the window, OutputVar is made blank. Otherwise, each unique ID is the window handle (HWND) of the control. Each item except the last is terminated by a linefeed (`n).
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.
Retrieves the degree of transparency of a window.
WinGet, OutputVar, Transparent , WinTitle, WinText, ExcludeTitle, ExcludeText
See WinSet for how to set transparency. OutputVar is made blank if: 1) the OS is older than Windows XP; 2) there are no matching windows; 3) the window has no transparency level; or 4) other conditions (caused by OS behavior) such as the window having been minimized, restored, and/or resized since it was made transparent. Otherwise, a number between 0 and 255 is stored, where 0 indicates an invisible window and 255 indicates an opaque window. For example:
MouseGetPos,,, MouseWin WinGet, Transparent, Transparent, ahk_id %MouseWin% ; Transparency of window under the mouse cursor.
Retrieves the color that is marked transparent in a window.
WinGet, OutputVar, TransColor , WinTitle, WinText, ExcludeTitle, ExcludeText
See WinSet for how to set the TransColor. OutputVar is made blank if: 1) the OS is older than Windows XP; 2) there are no matching windows; 3) the window has no transparent color; or 4) other conditions (caused by OS behavior) such as the window having been minimized, restored, and/or resized since it was made transparent. Otherwise, a six-digit hexadecimal RGB color is stored, e.g. 0x00CC99. For example:
MouseGetPos,,, MouseWin WinGet, TransColor, TransColor, ahk_id %MouseWin% ; TransColor of the window under the mouse cursor.
Retrieves an 8-digit hexadecimal number representing the style of a window.
WinGet, OutputVar, Style , WinTitle, WinText, ExcludeTitle, ExcludeText
If there are no matching windows, OutputVar is made blank. The following example determines whether a window has the WS_DISABLED style:
WinGet, Style, Style, My Window Title if (Style & 0x8000000) ; 0x8000000 is WS_DISABLED. MsgBox The window is disabled.
See the styles table for a partial listing of styles.
Retrieves an 8-digit hexadecimal number representing the extended style of a window.
WinGet, OutputVar, ExStyle , WinTitle, WinText, ExcludeTitle, ExcludeText
If there are no matching windows, OutputVar is made blank. The following example determines whether a window has the WS_EX_TOPMOST style (always-on-top):
WinGet, ExStyle, ExStyle, My Window Title if (ExStyle & 0x8) ; 0x8 is WS_EX_TOPMOST. MsgBox The window is always-on-top.
See the styles table for a partial listing of styles.
A window's ID number is valid only during its lifetime. In other words, if an application restarts, all of its windows will get new ID numbers.
ID numbers retrieved by this command are numeric (the prefix "ahk_id" is not included) and are stored in hexadecimal format regardless of the setting of SetFormat.
The ID of the window under the mouse cursor can be retrieved with MouseGetPos.
Although ID numbers are currently 32-bit unsigned integers, they may become 64-bit in future versions. Therefore, it is unsafe to perform numerical operations such as addition on these values because such operations require that their input strings be parsable as signed rather than unsigned integers.
Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
WinGetClass, Process, WinGetTitle, MouseGetPos, ControlGet, ControlFocus, GroupAdd
Maximizes the active window and reports its unique ID.
WinGet, active_id, ID, A WinMaximize, ahk_id %active_id% MsgBox, The active window's ID is "%active_id%".
Visits all windows on the entire system and displays info about each of them.
WinGet, id, List,,, Program Manager Loop, %id% { this_id := id%A_Index% WinActivate, ahk_id %this_id% WinGetClass, this_class, ahk_id %this_id% WinGetTitle, this_title, ahk_id %this_id% MsgBox, 4, , Visiting All Windows`n%A_Index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue? IfMsgBox, NO, break }