By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt WinWaitClose Function

Reference on AutoIts WinWaitClose function.

Edited: 2015-02-21 13:49

The WinWaitClose function will, when used, pause the script execution until a given window closes, at which point execution is resumed.

This function can be used in combination with WinExists, to handle situations where you want the script to be paused while a given window is alive.

If a timeout is provided, and the window is not closed within the provided timeout, the script will exit.

Returns 1 on success and 0 if the optional timeout was reached. If no timeout is provided, the function will keep checking in intervals of around 250 millisecond.


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

WinWaitClose examples

In the first example below, the script will continuously wait for the window to close. In the second example, it will wait a maximum of 10 seconds, after which the script simply exists, if the window is not closed within the timeout.

; Will wait for "[CLASS:Notepad]" to not exist

The following example includes a timeout:

; Will wait a maximum of 10 seconds "[CLASS:Notepad]" to not exist
; After which the script simply exits
WinWaitClose("[CLASS:Notepad]", "", 5)