Injecting Text Into Controls

Injecting Text Into Controls

The commands in this section are responsible for assisting the user to select credentials for an app, emulate the user typing into the app and for injecting text into the controls of a window.


SelectBookmark

Instructs the Desktop Agent to find the most suitable bookmark credentials for the running application.

Default behaviour, with no caption matching, is to use a matching bookmark automatically if only one is found. If many are found then a credential selection dialog is shown to the user.

If an application is started by clicking on a web vault tile then it is assumed that the credentials of the clicked tile are to be used.

Syntax Diagram

Parameters

bookmarkMatchOptions

Optional

The bookmarkMatchOptions are used to enable filtering on a user’s set of bookmarks for an app.

For example, the SAP GUI application is a single process that acts as a launcher to multiple connections. Using the bookmark matching feature makes it possible to associate a specific bookmark with a specific connection by comparing the text in a window’s caption or contained control.

If the user has many bookmarks for the SAP GUI app then without filtering they would be presented with a list of all bookmarks whether they were relevant for the selected target connection.

See the SAP GUI Application example for details.

The Caption option refers to the text in the currently selected control (from a SelectControl command) or the caption text of the current window if no control is selected.

The stringMatch controls how the filter text is compared to the window caption or control content. These are the same settings as the String Match Options

The bookmarkAttribute option is the text to be compared against that found in the current window or control. This may be a String (Text) Literals or one of the following bookmark attributes:

  • bmAppArgument

  • bmAppPath

  • bmEnc1

  • bmEnc2

  • bmTitle

  • bmNotes

  • bmUsername

AlertUser

Optional

If the AlertUser option is specified then the user is alerted via the notification pop-up if no bookmarks are found.

Example

// Automatically injects credentials if vault launched
// or if only one bookmark stored for the app.
SelectBookmark
// Select a bookmark if the foreground window's
// caption matches the value in the bookmark's
// second encrypted value field.
SelectBookmark Caption StartsWith bmEnc2

See the SAP GUI Application example for a comprehensive example.

Application Notes

The SelectBookmark command examines all the desktop bookmarks in the user’s vault that have the same Template as the running process. This identifies the set that are either presented to the user or subjected to subsequent filtering.


InteractiveSelectBookmark

The InteractiveSelectBookmark command displays a dialog box that allows the user to select a set of credentials and to have the username or password sent to a target field when the user clicks on a button in the dialog box.

The principle use case is with Flash or Java based websites where we cannot programmatically determine when the page is loaded. Using this command allows the user to tell the Desktop Agent when the target is ready for login.

Syntax Diagram

Parameters

Refer to the syntax diagrams for the valid combinations and positioning of the parameters.

Parameter

Shows Buttons

Description

SelectOnly

Send

The dialog only allows the user to select a user / password, the script controls injecting it into the target.

InjectUser

U (Inject Username)

Shows a button labelled “U” that will inject the username into the last field that the user clicked on.

InjectPassword

P (Inject Password)

Shows a button labelled “P” that will inject the password into the last field that the user clicked on.

Restrict

N/A

Only allows the text injection (by script or button) if the target window matches the restrictTo text. The match is deemed valid if the window’s caption contains the string or if the window’s process name contains the string.

MessageToUser

N/A

The text to display to the user on the pop up dialog box.

Example: Use of the SelectOnly option

InteractiveSelectBookmark SelectOnly Restrict "Dedoose" "When the Dedoosse page is loaded, select the required user below, then click Send."

Presents the user with the following dialog box:

Example: Use of the InjectUser & InjectPassword options

InteractiveSelectBookmark InjectUser InjectPassword Restrict "Dedoose" "When the Dedoosse page is loaded, select the required user below, then click Send."

Presents the user with the following dialog box:

Application Notes

See the “Flash Based Website” example Flash\Java Website for a fully described example.


SendKeys

The SendKeys command emulates user keyboard input by sending text to the script’s application’s top-most window.

This command attempts to bring the managed application’s window to the foreground prior to sending the text.

By default, if the script cannot confirm the application window is the foreground window then the text is not sent and a message is written to the log file. This may be overriden by the AnyWindow option.

The syntax here is quite complicated but it allows for a full set of characters mixed in with special keys, e.g. simulating pressing control and S at the same time.

To specify multiple modifier keystrokes at the one time (i.e. holding down control and shift as well as a key) concatenate the modifiers with the plus sign. See the examples.

SendKeys also understands how to emulate the user pressing a variety of special keys, such as Enter, Backspace, Caps Lock, Right Arrow, etc. These are listed in the Table of SendKeys Special Keys

Syntax Diagram

Parameters

AnyWindow

Overrides checking that the current foreground window belongs to the script’s application.

This weakens security, but in some scenarios this is necessary (primarily when scripting Flash / Java browser appps).

sendKeysConstant

This is literal text that is to be sent to the target app.

See String (Text) Literals

modifierCombination

A modifier combination allows the script to send special key strokes such as pressing Control and S at the same time.

The supported modifiers are:

  • ALT

  • CTRL

  • SHIFT

The modifiers are used, along with the ‘+’ symbol, to create any combination of key presses.

To emulate the user pressing control plus S the following command would be used:

SendKeys CTRL+s

To send Shift plus Alt plus V use:

SendKeys SHIFT+ALT+v

sendKeysBookmarkAttribute

This is any of the Bookmark & Template Attributes.

Note that these values are passed through literally, i.e. special key text (CTRL, etc.) are not converted in to the corresponding special key commands.

Examples

// Send a basic block of text
SendKeys "A string to be sent"

// Send a username, tab to the next control
// then send a password, then press Enter
SendKeys bmUsername TAB bmPassword ENTER

// To escape the double quote (") character
// just use it twice
SendKeys "Literal ""quotes"" here"

// Control, shift, alt and "m" all at the same time
SendKeys CTRL+SHIFT+ALT+m

SendKeys CTRL+SHIFT+ALT+ESCAPE

// Whitespace outside string constants is ignored
SendKeys "Text First" SHIFT+r ALT+x "Hello" CTRL+x

// Modifiers (SHIFT, ALT, CTRL) may be used on
// their own, not just as modifiers
SendKeys ALT ALT+x

Application Notes

The SendKeys command is translated into the Windows SendKeys syntax. For in-depth information on the limitations of this approach see the following Microsoft article:

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys


SendText

Used to change the text of the currently selected windows control (via SelectControl) or the window’s caption if no control is selected.

Unlike SendKeys the string parameter is passed unaltered to the target control. That is, the parameter is not sent to the application using Windows SendKeys.

SendKeys emulates user input while SendText is a low level write to a control that can be used to change the text on buttons, labels, etc.

Syntax Diagram

Parameters

concatenatedStringParameter (Mandatory)

This is the text to be sent to the selected control.

This may be composed of String (Text) Literals or Bookmark & Template Attributes.

Example

// Change the text of the selected control
// to "Login to <bookmark's title>"
SendText "Login to " bmTitle

Application Notes

SendText uses the Windows SENDTEXT message to write its text parameter to the window identified by the handle of the currently selected control (or current app’s window’s caption if no control selected).

    • Related Articles

    • String (Text) Literals

      Literal strings are text that you wish to pass straight through to a command, i.e. the text is not interpreted in any way. Types of Strings Strings may either be literal (fully defined in the script) or may come from values stored in bookmark ...
    • Desktop Scripting Overview

      Purpose The My1Login Desktop Scripting language is a Domain Specific Language (Desktop DSL), targeted at controlling and responding to Windows desktop applications, with the aim of injecting user credentials that are stored in the My1Login system. It ...
    • Desktop Client Commands

      Table of Script Commands Command Description AlertInfo / AlertError Commands to show text messages to users. BringToForeground Attempt to force the main app window to desktop’s foreground. InteractiveSelectBookmark Allows manual intervention when ...
    • Main Window Commands

      Main window commands are responsible for interacting with the primary window of an application, or the application itself rather than the current child window. BringToForeground The BringToForeground command is used to bring the main application into ...
    • Introductory Script Example

      This section describes a sample Windows application and shows how the My1Login desktop scripting language may be used to interact with it. This example is contrived, but it covers the features used by the majority of scripts. Sample Application ...