AutoIt WinExists Function

About AutoIts WinExists function, and example of how to use it.

2326 views

Edited: 2017-07-26 10:38

The WinExists function is used to check if a window exists.

If you got multiple windows, it can be more secure to perform the check using a window handle, rather than checking directly.

Normally you likely won't need to check for the existence of a window, but it can be a good idea, if there's a possibility that the window has been closed, by someone who is using the computer – either on purpose or by accident. Otherwise your script could, for example, start clicking unintended places.

Returns 1 on success and 0 on failure.

Parameters

TitleThe title of the window.Required
TextThe text of the window to read.Optional

WinExists example

If WinExists("[CLASS:Notepad]") Then
    MsgBox(0, "", "Window exists")
EndIf

Tell us what you think:

  1. How to declare and work with variables in AutoIt, as well as some background information.
  2. Everything you need to know about working with minimized windows.
  3. How to set the request headers when performing HTTP requests.
  4. This Tutorial will focus on post requests in AutoIt, using the Winhttprequest.5.1 object.
  5. How to use while, for, and do until loops, and how to loop through arrays and object in AutoIt.

More in: AutoIt Tutorials