Home > Language Reference > Wait Functions > Wait for a Menu Selection

Wait for a Menu Selection

The Pause until menu selected pauses script execution until the specified menu option has been selected. If after the specified timeout, the specified menu option has not been selected, the block of statements following PauseFalse keyword is executed.

Usage

Used very rarely, the Wait for a Keystroke is usually preferred. Use Insert/Wait For/Menu menu to generate easily such a Pause.

Syntax

Pause [x secs] until
    Menu(<menu_item>) 
    [InWindow(<window_name>,<instance>)]
    [InModule(<application_name>)]
[PauseOK|PauseTrue]
 'If the key is pressed, the optional statements after the PauseOK and before the PauseFalse are executed
[PauseFalse]
' After the specified timeout, if the key has not been pressed, the statements after the PauseFalse are executed
     MsgBox("Pause at line "+ #ErrorLine$ +" has failed !",16,"Runtime error")
     End
EndPause

Parameters

[x secs], optional. If the menu option has not been selected 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.

Menu, keyword. It specifies in <menu_item> the menu selection to wait. Use Insert/Wait For/Menu menu option to generate the correct <menu_item> syntax.

InWindow, optional keyword. If specified, the condition is met only when the menu option is selected within the window specified by <window_name> and its <instance> number. 

InModule, optional keyword. If specified, the condition is met only when the menu option is selected within the application specified by <application_name>

See also

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

Example

Shell("notepad",1)
Pause until
     Menu("&Edit|Time/&Date F5")
     InModule("NOTEPAD.EXE")
PauseFalse
     MsgBox("'Wait for' at line " + #ErrorLine$ + " has failed !")
     End
EndPause