Keystrokes package guide
Send literal text, named keys and held-key shortcuts to a Windows application.
Version 2.16.2. Installed versions can differ. Examples are illustrative and not tested. See Packages.
Prerequisites
Use a Windows Device with compatible Mercury and a desktop that is signed in, unlocked and connected. The target window must accept input. The step brings the window to the front, but it does not click into a field. Click the field first, or use Capture.
For the example, capture a blank Notepad window and save it in Window $sampleWindow$ with Window / Attach or open. For Credential mode, make Credential $sampleCredential$ with a test password, and try it only in a test field. Only the password is typed, as stored, with its brackets. The user name is not typed.
Write keys as [NAME], [NAME DOWN] and [NAME UP], for example [TAB], [ENTER] or [CTRL DOWN]a[CTRL UP]. Key names ignore case, spaces and hyphens, so [PAGE-UP] and [PAGE UP] are the same. The step accepts F1 through F24, the arrows, Home, End, Delete, Shift, Ctrl, Alt, Win and the other usual Windows key names. An unknown name or a bracket that is not closed makes the step fail. Close the sample application after the test.
Actions
Simulate keystrokes (keystrokesSimulate)
Type text and named keys into a window.
Inputs
| Input | Editor field | Type; default; editor rule | Value |
|---|---|---|---|
window | Window | Windowdefault emptyoptional. | The window to type into: a captured Window such as $sample, or a title such as Notepad. Empty: the window that has focus when typing starts. |
window | Window title is | Windowdefault Containsoptional. | Contains: part of the title. Exact: the full title. Wildcard: * is any text, ? is one character. Regex: a regular expression. Active: the window in front, whatever its title. Case is ignored, unless the Window has its own rule. |
type | Keys from | Inputdefault VALUEoptional. | VALUE: the text and bracket keys in string. CREDENTIAL: the Credential password, typed as it is. |
string | Keystrokes | Keysdefault emptyoptional. | For VALUE: text and keys, such as Invoice sample[ENTER]Ready. [CTRL DOWN]a[CTRL UP] sends Ctrl+A. Inside a held key, an uppercase letter can add Shift, so use lowercase. Type [DOLLAR] for a $ sign. A new line sends Enter. Send an UP for each DOWN. |
cv | Select a credential | Credentialdefault empty Credentialoptional. | For CREDENTIAL: a Credential such as $sample. An empty password makes the step fail. Do not paste passwords in Keystrokes. |
delay | Delay between each keystroke in ms | Numberdefault 10optional. | The pause after each key, in whole milliseconds. 0 or less: no pause. Before each key, the step checks the named window and brings it back if focus moved. |
Outputs
No output fields.
Example
Set windowValue=$sampleWindow$, windowValueMatch=Contains, typeOfInputStringToType=VALUE, stringToType=Invoice sample[ENTER]Ready and delay=10. Leave cvToType empty. Send [CTRL DOWN]a[CTRL UP] in a second step. It selects without deleting.
Expected result
The two lines are Invoice sample and Ready. The second step selects both lines. An unknown key name or a bracket that is not closed fails before focus changes. A locked or disconnected desktop refuses the keys. A key sent with DOWN stays pressed until you send UP, also after the step ends.