Function Reference


WinActive

Checks to see if a specified window exists and is currently active.

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

Parameters

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

Return Value

Success: the handle to the window if it is active.
Failure: 0 otherwise.

Related

WinExists, WinTitleMatchMode (Option), WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive

Example

#include <MsgBoxConstants.au3>

If WinActive("[CLASS:Notepad]") Then ; Check if Notepad is currently active.
        MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is active.")
Else
        MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is not active.")
EndIf