Function Reference


WinExists

Checks to see if a specified window exists.

WinExists ( "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: 1.
Failure: 0 if the window is not found.

Remarks

WinExists() will return 1 even if the window is hidden.

Related

ProcessExists, WinActive, WinClose, WinTitleMatchMode (Option), WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive

Example

#include <MsgBoxConstants.au3>

Example()

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

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

    ; Test if the window exists and display the results.
    If WinExists("[CLASS:Notepad]") Then
        MsgBox($MB_SYSTEMMODAL, "", "Window exists")
    Else
        MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "Window does not exist")
    EndIf

    ; Close the Notepad window.
    WinClose("[CLASS:Notepad]", "")
EndFunc   ;==>Example