Waits until the specified window exists.

WinWait WinTitle, WinText, Timeout, ExcludeTitle, ExcludeText



Type: String, Integer or Object

A window title or other criteria identifying the target window. See WinTitle.

WinTitle may be blank only when WinText, ExcludeTitle, or ExcludeText is present.


Type: String

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.


Type: Integer or Float

How many seconds to wait before timing out and returning 0. Leave blank to allow the function to wait indefinitely.


Type: String

Windows whose titles include this value will not be considered.


Type: String

Windows whose text include this value will not be considered.

Return Value

Type: Integer

This function returns the HWND (unique ID) of a matching window if one was found, or 0 if the function timed out.


If a matching window comes into existence, the function will not wait for Timeout to expire. Instead, it will update the Last Found Window and return, allowing the script to continue execution.

If WinTitle specifies an invalid HWND (either as an Integer or via the Hwnd property of an object), the function returns immediately, without waiting for Timeout to expire. Waiting for another window to be created with the same HWND value would not be meaningful, as there would likely be no relation between the two windows.

While the function is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.

If another thread changes the contents of any variable(s) that were used for this function's parameters, the function will not see the change -- it will continue to use the title and text that were originally present in the variables when the function first started waiting.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on, even if WinTitle is a HWND or object.

WinWaitActive, WinWaitClose, WinExist, WinActive, ProcessWait, SetTitleMatchMode, DetectHiddenWindows


Opens Notepad and waits a maximum of 3 seconds until it exists. If WinWait times out, an error message is shown, otherwise Notepad is minimized.

Run "notepad.exe"
if WinWait("Untitled - Notepad", , 3)
    WinMinimize ; Use the window found by WinWait.
    MsgBox "WinWait timed out."