# Function Reference

# _WinAPI_GetGUIThreadInfo

Retrieves information about the active window or a specified GUI thread

#include <WinAPISysWin.au3>
_WinAPI_GetGUIThreadInfo ( $iThreadId )

## Parameters

$iThreadId | The identifier for the thread for which information is to be retrieved.

## Return Value

Success: | The array that contains the following information: [0] - The thread state. It can be one or more of the $GUI_* values. [1] - A handle to the active window within the thread. [2] - A handle to the window that has the keyboard focus. [3] - A handle to the window that has captured the mouse. [4] - A handle to the window that owns any active menus. [5] - A handle to the window in a move or size loop. [6] - A handle to the window that is displaying the caret. [7] - The x-coordinate of the upper-left corner of the caret's bounding rectangle, in client coordinates. [8] - The y-coordinate of the upper-left corner of the caret's bounding rectangle, in client coordinates. [9] - The width of the caret's bounding rectangle. [10] - The height of the caret's bounding rectangle.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

## See Also

Search GetGUIThreadInfo in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <WinAPISysWin.au3>
    #include <WindowsStylesConstants.au3>

    Local $hForm = GUICreate('', 240, 268, 10, 10, BitOR($WS_CAPTION, $WS_POPUP), $WS_EX_TOPMOST)
    GUICtrlCreateLabel('Thread state:', 20, 18, 90, 14)
    GUICtrlCreateLabel('Active window:', 20, 40, 90, 14)
    GUICtrlCreateLabel('Keyboard focus:', 20, 62, 90, 14)
    GUICtrlCreateLabel('Mouse capture:', 20, 84, 90, 14)
    GUICtrlCreateLabel('Active menu:', 20, 106, 90, 14)
    GUICtrlCreateLabel('Move or size loop:', 20, 128, 90, 14)
    GUICtrlCreateLabel('Caret:', 20, 150, 90, 14)
    GUICtrlCreateLabel('Left:', 20, 172, 90, 14)
    GUICtrlCreateLabel('Top:', 20, 194, 90, 14)
    GUICtrlCreateLabel('Width:', 20, 216, 90, 14)
    GUICtrlCreateLabel('Height:', 20, 238, 90, 14)
    Local $a_idLbl[11]
    For $i = 0 To 10
        $a_idLbl[$i] = GUICtrlCreateLabel('', 114, 18 + 22 * $i, 116, 14)
    Next
    GUISetState(@SW_SHOWNOACTIVATE)

    Local $hWnd, $aInfo, $iPID
    Do
        $hWnd = WinGetHandle('[ACTIVE]')
        $aInfo = _WinAPI_GetGUIThreadInfo(_WinAPI_GetWindowThreadProcessId($hWnd, $iPID))
        If Not @error Then
            WinSetTitle($hForm, '', WinGetTitle($hWnd))
            $aInfo[0] = '0x' & Hex($aInfo[0], 8)
        Else
            WinSetTitle($hForm, '', '')
            Dim $aInfo[11]
            For $i = 0 To 10
                $aInfo[$i] = ''
            Next
            $hWnd = 0
        EndIf
        For $i = 0 To 10
            If StringCompare(GUICtrlRead($a_idLbl[$i]), $aInfo[$i]) Then
                GUICtrlSetData($a_idLbl[$i], $aInfo[$i])
            EndIf
        Next
    Until GUIGetMsg() = $GUI_EVENT_CLOSE