WaitForWindow

The WaitForWindow command suspends execution of the script until a desired window appears in the foreground.

Note

This command works only for legacy Dragon version 5 commands that have been imported into version 8. It will not work in commands that you create using the MyCommands editor.

Syntax

WaitForWindow caption [, windowClass [, timeout ] ]

Argument Description
caption A text string to match against the window caption. The string may (and often will) include the asterisk (*) character as a wild-card to match against variable parts of the window caption. If parts of the actual window caption are guaranteed to be unpredictable, you MUST use an * wild-card to get a successful match.

The caption may also be an empty string "," to indicate that the caption does not matter.
windowClass A text string which, when not empty (""), must exactly match (case-sensitive) the window class name of the window you are looking for. The window class name is usually obtainable only through programmer utilities like "Spy".
timeout The length of time, in milliseconds, to wait for the window to appear. If no matching window appears by then, a timeout error is displayed, and the script stops without executing any subsequent commands following WaitForWindow. If not specified, defaults to 10 seconds.

Examples

In the following example the * in the caption is an instruction to ignore "Document1".

AppBringUp "(correct path here)winword.exe"
WaitForWindow "*Microsoft Word"
SendKeys "this text will appear in the Word document, not the splash screen"

The following example waits for Word's main window by class name.

AppBringUp "(correct path here)winword.exe"
WaitForWindow "," "OpusApp"
SendKeys "this text will appear in the Word document, not the splash screen"

The following example starts Microsoft Outlook, waits as long as 30 seconds in case the network is slow, and then types Alt+n to create a new E-mail.

AppBringUp "(correct path)outlook.exe"
WaitForWindow "*Microsoft Outlook", "," 30000
SendSystemKeys "{Alt+n}"