Structure of a Script
A Desktop DSL Script has the following functional sections (not all are required for all apps):
- Error Directive
- Process Start and Identification
- Child Window Responses
- Main Window level commands
This section only gives a flavour of the commands mentioned, the reference section and examples give full details on their use.
Error Directive
The OnError
directive is used to control how any errors are handled and whether they are shown to the user.
The options are to either stop all processing or to continue with it and, independently, to show, or not show, the error to the user.
For example, the following will stop the script processing and show a notification to the user.
OnError Terminate AlertUser
The OnError
directive may be used at multiple points in a script. It is possible that a command in a script throws an error if an application is in a specific state, but that this is not fatal to the execution of the script. In such cases it may be preferable to temporarily change the error handling to permit this.
// Do not stop the script and do not
// inform the user of the error
OnError Continue
<Some command(s) that may cause a recoverable error>
// Switch back to normal error handling
OnError Terminate AlertUser
Process Start and Identification
The Process Start and Identification section is responsible for ensuring that the Desktop DSL Script knows which windows process is to be handled by the remainder of the script, it is comprised of two commands, always in the following order:
StartProcess <options>
WaitProcess <option>
A Desktop DSL Script may be triggered by a windows app in one of two ways:
The user clicks on a tile in their Vault.
The user starts an application via a desktop shortcut or command line.
If the user clicks on a Vault tile, then this means that there is not a windows application (process) currently running. Therefore, the script must start the appropriate process. This is performed by the StartProcess
command.
The WaitProcess
command is used to prevent any further processing of the script until the Desktop Agent is sure that the required process is running.
Getting the start and wait processes commands correctly configured is essential to allowing the remainder of the script to work correctly. Many line of business applications use a pattern where the process that is started is not the process that the user interacts with, the Desktop DSL refers to this as a Morphing process. The detailed notes on the command reference and the examples show how this should be configured.
Alternatively the script may open a URL in the user’s default browser.
Child Window Responses
The WhenWindow
command allows you to define a set of script commands that are only run when a child window of the application comes to the foreground.
There are options to allow fine control over matching the target window, e.g:
The caption of the window.
The existence of specific controls within the window.
Text on controls within the window.
Main Window Commands
The main window commands are those that interact with the controls on the current application window, e.g.:
Send text to the current control.
Select a control.
Send a mouse click.
Force a window to the forground.
Pause the script for a period of time.
Present the user with a dialog box to control the login (used for Flash and java based web sites).
Show a message to the logged in user.
Write a message to the log file.