Wait for Process
Verb: waitProcess
Available from: <Standard>
Waits for a period of time defined in the Timeout parameter, for a "process" to start or end, identifying it by its Id or Name.
A process consists of an instance of a computer program that is running.
Syntax
waitProcess --mode(WaitForProcessMode) --by(ProcessBy) --id(Numeric) [--useRegex(Boolean)] --name(String) --regexPattern(String) [--regexOptions(DisplayableRegexOptions)] [--sessionsearch(Nullable<ProcessSessionSearch>)] --sessionid(Numeric) [--timeout(TimeSpan)] (Boolean)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--mode | What to wait for | Required | WaitForProcessMode | Type of event to wait for:
|
--by | Find by | Required | ProcessBy | Selector type to find the process. These are the available options:
|
--id | Id | Only whenFind by is Id | Number | Id of the process. |
--useRegex | Use regular expression | Optional | Boolean | Enables searching for the process using a regular expression. |
--name | Process name | Only whenUse regular expression is False | Text | Name of the process. |
--regexPattern | Regular expression | Only whenUse regular expression is True | Text | Regular expression used to find the process. |
--regexOptions | Options | Optional | DisplayableRegexOptions | Regular expression options. You can select more than one of the following:
|
--sessionsearch | Session search directive | Optional | ProcessSessionSearch | Session in which the process should be searched for.
|
--sessionid | Session id | Only whenSession search directive is SpecifiedSession | Number | Id of the session that should be fetched. |
--regex | Use regular expression(Obsolete) | Optional | Boolean | When enabled, allows the use of a "Regular Expression" to search for the process.
This parameter is obsolete, the Use regular expression parameter should be used instead. |
--ignorecase | Ignore case(Obsolete) | Optional | Boolean | When enabled, specifies case-insensitive matching.
This parameter is obsolete. To select regular expression options, use the Options instead. |
--dotmatchesnewline | Dot matches new line(Obsolete) | Optional | Boolean | When enabled, the dot (.) character matches every character, instead of every character except "\n".
This parameter is obsolete. To select regular expression options, use the Options instead. |
--freespacing | Ignore white space(Obsolete) | Optional | Boolean | When enabled, eliminates blank spaces and breaks without adding a escape character.
This parameter is obsolete. To select regular expression options, use the Options instead. |
--explicitcapture | Explicit capture(Obsolete) | Optional | Boolean | When enabled, specifies that the only valid captures are explicitly named or numbered groups of the form (?
This parameter is obsolete. To select regular expression options, use the Options instead. |
--multiline | Multiline(Obsolete) | Optional | Boolean | When enabled, changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
This parameter is obsolete. To select regular expression options, use the Options instead. |
--timeout | Timeout | Optional | Time Span, Number, Text | Maximum wait time to find the process. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Success | Boolean | "True" if the process was started or terminated successfully, or "False" if it was not started nor terminated successfully. |
Example
Waits for 10 seconds for the Notepad process to start.
defVar --name waitResult --type Boolean
defVar --name associatedStartedWindow --type Window
defVar --name processId --type Numeric
defVar --name startWindowSuccess --type Boolean
defVar --name closeProcessResult --type Boolean
launchWindow --executablepath "notepad.exe" associatedStartedWindow=value processId=processId startWindowSuccess=success
waitProcess --mode "Start" --by "Name" --useRegex --regexPattern notepad --regexOptions "0" --sessionsearch "AllSessions" --timeout 00:00:10 waitResult=value
//Displays in the console if the process has started.
logMessage --message "Process Start: ${waitResult}" --type "Info"
closeProcess --by "Id" --id ${processId} closeProcessResult=value
//Displays in the console if the process has been terminated.
logMessage --message "Process terminated: ${closeProcessResult}" --type "Info"
Remarks
In the Regular expression parameter, you can use the Regular Expression Editor via the toolbar in the Tools menu or by clicking on the corresponding editor icon in the command interface.
If no value is set in Timeout, the context time defined by Set Timeout is used. If this command is not used, the default time is 5 seconds.