WinWaitClose

Waits until the specified window does not exist.

WinWaitClose , WinTitle, WinText, Timeout, ExcludeTitle, ExcludeText

Parameters

WinTitle, WinText, ExcludeTitle, ExcludeText

If each of these is blank or omitted, the Last Found Window will be used. Otherwise, specify for WinTitle a window title or other criteria to identify the target window and/or for WinText a substring from a single text element of the target window (as revealed by the included Window Spy utility).

ExcludeTitle and ExcludeText can be used to exclude one or more windows by their title or text. Their specification is similar to WinTitle and WinText, except that ExcludeTitle does not recognize any criteria other than the window title.

Window titles and text are case-sensitive. By default, hidden windows are not detected and hidden text elements are detected, unless changed with DetectHiddenWindows and DetectHiddenText. By default, a window title must start with the specified WinTitle or ExcludeTitle to be a match, unless changed with SetTitleMatchMode.

Timeout

If blank or omitted, the command will wait indefinitely. Otherwise, it will wait no longer than this many seconds. To wait for a fraction of a second, specify a floating-point number, for example, 0.25 to wait for a maximum of 250 milliseconds. Specifying 0 is the same as specifying 0.5. This parameter can be an expression.

ErrorLevel

ErrorLevel is set to 1 if the command timed out or 0 otherwise.

Remarks

Whenever no instances of the specified window exist, the command will not wait for Timeout to expire. Instead, it will immediately set ErrorLevel to 0 and the script will continue executing.

While the command 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 command's parameters, the command will not see the change -- it will continue to use the title and text that were originally present in the variables when the command first started waiting.

WinClose, WinWait, WinWaitActive, WinExist(), WinActive(), Process, SetTitleMatchMode, DetectHiddenWindows

Examples

Opens Notepad, waits until it exists and then waits until it is closed.

Run, notepad.exe
WinWait, Untitled - Notepad
WinWaitClose ; Use the window found by WinWait.
MsgBox, Notepad is now closed.