This section introduces a basic script that interacts with the windows Notepad application.
The script does three things:
It inserts some text in the Notepad window when Notepad starts.
It shows a message to the user when the About box is shown.
It automatically opens the About box after the text has been displayed.
This simple script covers all the main sections of the scripting language.
The Script Reference covers all commands in detail, along with some real world example scripts.
The desktop scripting language expects standard quote symbols (“).
Some editors, e.g. Word, substitute decorative quotes when you type in standard quote symbols.
The image below shows the effect of pasting text into Word and what it should look like.
This is the most common cause of error if copying and pasting scripts from Word or Outlook emails.
Scripting a desktop app involves:
Creating an app template in the My1Login admin area that describes the application and holds the script.
Identifying the executable that starts the app.
Identifying those aspects of the app that are relevant to scripting, e.g. dialog boxes, controls.
Writing and testing the script.
In the admin / Apps area of My1Login a desktop app is defined.
The image below shows a configuration that will start the Notepad app. The Require Credentials option is cleared because we do not need to login to Notepad. Some customers make use of this option to have the Desktop Client act as a smart shortcut to apps.
The Notepad application is on the path, so no folder is required.
The following script starts off by being configured to stop running and warn the user if there is a runtime error.
It then starts the Notepad process, if launched from the web vault. It knows to start Notepad because bmAppPath
returns the contents of the “Path to App” field from the configuration. There are similar variables available for all template and bookmark fields.
The script then waits until it detects that the process is running.
Finally the script sends some text into Notepad. This shows the use of some other configuration variables. The SendKeys
command is capable of sending special command sequences to simulate the user pressing keys such as Control or Alt, etc.
OnError Terminate AlertUser
StartProcess bmAppPath
WaitProcess bmAppPath
SendKeys "Hello to " bmAppPath " from the template " bmTemplateName " (" bmTemplateDescription ")"
This produces the following output:
We will now extend the script such that whenever the Notepad’s About Box is shown it displays a message to the user.
On opening the About Box we can see it has a tile of “About Notepad”.
In the script, below, the WhenWindow command monitors the windows desktop and, when a window comes into focus and it has the caption “About Notepad”, it runs the commands between the following {}s.
OnError Terminate AlertUser
StartProcess bmAppPath
WaitProcess bmAppPath
SendKeys "Hello to " bmAppPath " from the template " bmTemplateName " (" bmTemplateDescription ")"
WhenWindow "About Notepad"
{
AlertInfo "Hello from " bmTemplateName, "My1Login Desktop Message"
}
In this case a message is displayed in the notification area, as shown below:
Finally, we’ll add a command to open the About Box automatically.
Note
This command relies on the WhenWindow configuration, therefore it must appear after the WhenWindow command.
OnError Terminate AlertUser
StartProcess bmAppPath
WaitProcess bmAppPath
SendKeys "Hello to " bmAppPath " from the template " bmTemplateName " (" bmTemplateDescription ")"
WhenWindow "About Notepad"
{
AlertInfo "Hello from " bmTemplateName, "My1Login Desktop Message"
}
// Open the About Box
SendKeys ALT+h "a"
Note
The script uses ALT+h
to open the Help menu, followed by the a
character to select the About option.