Wait for Window to Appear

Waits for an open window, and stores it in a Window type variable.

Description

Waits for an open window that corresponds to the specified selectors to appear, storing that window in a Window type variable. The stored window is automatically attached to the driver's active window context. You can use it to verify if a window is open, or when changing the focus between multiple windows.

To obtain the selectors from a window, refer to Controls and selectors overview for a detailed explanation.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

waitWindow [--useregex(Boolean)] [--title(String)] --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] [--id(String)] [--classname(String)] [--processid(Numeric)] [--processname(String)] [--byparent(Boolean)] [--window(Window)] [--recursive(Boolean)] [--safesearch(Boolean)] [--styles(Nullable<AutomationWindowStyles>)] [--minimumheight(Numeric)] [--minimumwidth(Numeric)] [--timeout(TimeSpan)] (Window)=value (Numeric)=processId (Boolean)=success

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Use Regular Expression useregex Optional Boolean Enable to use a regular expression to identify the window that should be waited for.
Title title Optional Text Title of the window that should be waited for.
Regular Expression regexPattern Required only when Use Regular Expression is True Text Regular expression used to identify the window that should be waited for.
Options regexOptions Optional DisplayableRegexOptions Options for regular expression matching.

See the regexoptions parameter options.
Identifier id Optional Text Id of the window that should be waited for.
Class Name classname Optional Text Class name of the window that should be waited for.
Process Id processid Optional Number Id of the process that the window belongs to.
Process Name processname Optional Text Name of the process thatthe window belongs to.
Wait child window byparent Optional Boolean Enable to allow waiting for child windows of a parent window.
Window window Optional Window Parent of the child window that you want to wait for.
Recursive recursive Optional Boolean Enable to allow waiting for windows within a window.
Safe Search safesearch Optional Boolean Enable to run a higher performance window search algorithm.
Styles styles Optional AutomationWindowStyles Awaited window styles: Child, Dialog.
Minimum Height minimumheight Optional Number Minimum height of the awaited window.
Minimum Width minimumwidth Optional Number Minimum width of the awaited window.
Timeout timeout Optional Time Span, Number, Text Command execution timeout. If no value is defined in the timeout parameter, the execution uses the context time defined by the Set Timeout (setTimeout) command. If the script does not use this command, the default time is 5 seconds.

regexOptions parameter options

The following table displays the options available for the regexOptions input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
Compiled Compiled Compile regex expressions instead of interpreting.
Culture Invariant CultureInvariant Ignore cultural differences in language.
ECMA Script ECMAScript Interprets ECMA Script expressions.
Ignore Case IgnoreCase Case-insensitive search.
Explicit Capture ExplicitCapture The only valid captures are explicitly named or numbered groups of the form (?<name> subexpression).
Ignore Pattern Whitespace IgnorePatternWhitespace Ignore whitespace characters, and enable comments after a number sign (#).
Right To Left RightToLeft Read regex expressions from right to left, or from last to first.
Singleline Singleline Changes the meaning of the dot (.), which matches every character except
.
Multiline Multiline Allows the caret (^) and dollar sign ($) symbols to match newline characters.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Window value Window Returns the awaited window.
Process Id processId Number Returns the process Id.
Success success Boolean Returns True if the window was found, or False otherwise.

Example

In this particular example, the command verifies if the Outlook application is open. If it is not, it runs a subroutine to start the Outlook application. After starting the application and attaching it automatically to the driver's active window context, a search filter is applied based on a list of excluded words. Then, it returns the amount of emails that have any word from the list.

defVar --name windowStatus --type Boolean
defVar --name outlookConnection --type EmailConnection
defVar --name countMessages --type Numeric
defVar --name listExcludeWords --type List --innertype String --value "[word1,word2,word3]"
// Verifies if the Outlook application is opened.
waitWindow --title "Inbox <-user@ibm.com|-user@ibm.com> - Outlook" --classname rctrl_renwnd32 --processname outlook windowStatus=success
// Runs a subroutine to start the Outlook application in case it is not open.
gosubIf --label openOutlook --left "${windowStatus}" --operator "Is_True" --negate
// Connects to the Outlook application.
outlookConnect --mailusername "useremail@email.com" outlookConnection=value
// Applies search filters, in this case, based on a list of excluded words.
emailApplySearchFilters --folderpath Inbox --subjectdirective "All" --exclusivesubject ${listExcludeWords} --wordsdirective "All" --connection ${outlookConnection}
// Counts the amount of emails returned based on the filter.
emailCount --connection ${outlookConnection} countMessages=value
// Prints the amount of emails that have any word from the excluded words list.
logMessage --message "Quantity of emails that have words from the list of excluded words: ${countMessages}" --type "Info"
beginSub --name openOutlook
// The subroutine to start the Outlook application.
	launchWindow --executablepath "C:\\Program Files\\Microsoft Office\\root\\Office16\\outlook.exe"
endSub