Home > Language Reference > Wait Functions > Wait for a Window

Wait for a Window

The Pause until winstatus pauses script execution until the specified window exists, not exists, is active, is not active. If after the specified timeout, the pause condition is not met, the block of statements following PauseFalse keyword is executed.

 Video: How to use Window Synchronization


Used to wait for the disappearance of a window generated by an application. For example, when you download a file, you could use Pause until "Completed" window disappears before performing further actions. Use Recording mode or Insert/Synchronization on window menu to generate easily such a Pause.


Pause [x secs] until
    WinStatus(Exists|NotExists|Active|NotActive [,Exact|Near])
 'If the condition is met, the optional statements after the PauseOK and before the PauseFalse are executed
' After the specified timeout, if the condition is not met, the statements after the PauseFalse are executed
     MsgBox("Pause at line "+ #ErrorLine$ +" has failed !",16,"Runtime error")


[x secs], optional. If the pause condition is not met after x seconds, the statements after the PauseFalse keyword are executed. If not specified, the default timeout is the one as defined by #PauseTimeout system variable (default value: 120 seconds). mins can be used instead of secs for a timeout in minutes. 

WinStatus, keyword, window state triggering the pause condition.
 Keyword  Condition met when
 Exists  The specified window exists
 NotExists  The specified window does not exist
 Active         The specified window is active (can receive actions)
 NotActive      The specified window is not active
 Exact  Triggers when an exact window name matches
 Near  Triggers when a window name near from the specified one matches (default value)

InWindow|InWindowAnyInstance, keyword. It specifies the <window_name> of the window to wait. <instance> is not specified if InWindowAnyInstance is used (then the specified window whatever its instance will trigger).


UseWindow function is enough to wait until the specified window is displayed, so do not use a Pause window for detecting a new window. If the window takes more than 30 seconds to appear, UseWindow will fail, but you can increase this default timeout using #ActionTimeout.

See also

Wait for a Date
Wait for Image
Wait for a Keystroke
Wait for a Menu Selection
Wait for a Mouse Click
Wait for OCR Text
Wait for a Text
Wait for a Time Delay


'This example just shows the Pause syntax.
'In this example, a UseWindow("NOTEPAD.EXE|#32770|Notepad") would be enough and much simpler
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
     SendKeys("Hello Tester")
Pause 10 secs until
     WinStatus(Active, Exact)
     MsgBox("'Wait for' at line " + #ErrorLine$ + " has failed !")
 Click(Button,"Do&n't Save")