Check if a window exists with AutoIt
How to check if a window exists using AutoIt
6217 views

Edited: 2017-07-26 10:41
If you want to check if a given window exists with AutoIt, you will at least need to know the title of the window, alternatively you can also use the window classname.
A single check can be performed using the WinExists function inside an If statement.
If WinExists("[CLASS:Notepad]") Then MsgBox(0, "", "Window exists") EndIf
Waiting for the window to appear
You can also, if needed, use the WinWait function, which allows you to make your script wait for the window to first appear, and create a window handle that you can re-use throughout your script.
$hWnd = WinWait("[CLASS:Notepad]", "", 10) sleep(10000) If WinExists($hWnd) Then MsgBox(0, "", "Window exists") ElseIF MsgBox(0, "", "Window does not exist") EndIf
If the window is closed, and a new window opened, the script will show a message that the original window no longer exists.
Tell us what you think: