Function Reference


WinGetState

Retrieves the state of a given window.

WinGetState ( "title" [, "text"] )

Parameters

title The title/hWnd/class of the window to get the state. See Title special definition.
text [optional] The text of the window to get the state. Default is an empty string. See Text special definition.

Return Value

Success: a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in:
$WIN_STATE_EXISTS (1) = Window exists
$WIN_STATE_VISIBLE (2) = Window is visible
$WIN_STATE_ENABLED (4) = Window is enabled
$WIN_STATE_ACTIVE (8) = Window is active
$WIN_STATE_MINIMIZED (16) = Window is minimized
$WIN_STATE_MAXIMIZED (32) = Window is maximized
Failure: 0 and sets the @error flag to non-zero if the window is not found.

Constants are defined in "AutoItConstants.au3".

Related

BitAND, WinGetPos, WinSetState

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        ; Run Notepad
        Run("notepad.exe")

        ; Wait 10 seconds for the Notepad window to appear.
        Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

        ; Retrieve the state of the Notepad window using the handle returned by WinWait.
        Local $iState = WinGetState($hWnd)

        ; Check if the Notepad window is minimized and display the appropriate message box.
        If BitAND($iState, $WIN_STATE_MINIMIZED) Then
                MsgBox($MB_SYSTEMMODAL, "", "Notepad is minimized and the state returned by WinGetState was - " & $iState)
        Else
                MsgBox($MB_SYSTEMMODAL, "", "Notepad isn't minimized and the state returned by WinGetState was - " & $iState)
        EndIf

        ; Close the Notepad window using the handle returned by WinWait.
        WinClose($hWnd)
EndFunc   ;==>Example