Send Keystrokes Action Icon

Send Keystrokes Action

Declaration

<AMSENDKEY METHOD="text [options]" DELAYBETWEENKEYS="number" DOS="yes/no" PREDELAY="number" STAYFOCUSED="yes/no" LOCKKEYBOARD="yes/no">text</AMSENDKEY>

See Also

Run, Hold Down Key, Release Key, Mouse

Description

Sends the keystrokes to the currently focused (front) window. Keystrokes can either be sent one-by-one using the "Simulate Keypress" option (use when selecting buttons or menu items) or can be pasted all at once using the "paste characters" option (use when typing large amounts of text such as the body of an email message). Special keystrokes such as ALT, CTRL, and SHIFT should be selected from the "Special Keystrokes" button and will only work when the "Simulate Keypress" option is selected.

Practical Usage

Send Keystrokes is one of the most commonly used actions in AutoMate. It is used primarily to simulate keystrokes being typed into an application. For example the first step in a task could be to open the application using the Run action <AMRUN>, the next would be Send Keystrokes which could send the keystroke "ALT-f r" to activate the file menu in the Application and select the Properties menu option.

Parameters

General Tab

Method
Options, Optional - Default KEYPRESS
MARKUP:
a) METHOD="keypress"
b) METHOD="paste"

Specifies the manner by which the keystrokes should be sent.

There are two available options:
keypress
: Simulate Keypress - The keystrokes will be typed into the application one by one and generate key press events on the system. Use this option to click buttons and select menu options and activate accelerator and hot keys in an application
paste
: Paste characters - The characters will be "pasted" into the application all at once using the Windows clipboard. Existing Clipboard contents will remain intact. Use this option to send large chucks of text into an application, since all the characters are inserted at one time this will substantially speed up task execution. The paste option is not able to select menus, buttons or other controls, it can only work in text fields.

Keystrokes
Text, Required
MARKUP: ...>This is a test to activate the file menu {ALT}f"</AMSENDKEY>

Specifies the keystrokes to send to the currently focused application. For alpha-numeric characters, the literal keystrokes that AutoMate should send should be specified. Case is preserved, so to send the value "Steve" is not necessary to enter the code for the shift key, rather simply enter "Steve" (without quotes of course).

A "special keystrokes" button is provided for easy selection of special keys such as ALT, SHIFT and function keys. For details on how to use special keystrokes such as ALT, SHIFT, function keys, the number-pad and more, see the Notes section below.

Transpose special keystrokes as you type (visual mode only option)
Yes\No, Optional - Default NO
MARKUP: NONE (visual interface only)

Causes all keystrokes to be taken literally in the Keystrokes parameter.

Advanced Tab

Add a pause before Sending/pasting keys
Number, Optional - Default 100
MARKUP: PREDELAY="200"

The amount of time (in milliseconds) to wait when the step is executed before actually sending the keystrokes. This is enabled by default to give the application time to be ready to receive input before the keystrokes are sent. Although the fact that the Run Action can wait until the application is ready for input before continuing - a small delay may still be required here and may need to be adjusted according to the specific application and system speed.

Add a delay between individual keystrokes
Number, Optional - Default 25
MARKUP: DELAYBETWEENKEYS="200"

The amount of time (in milliseconds) to wait between each keypress. This is enabled by default to give the application time to process each keystroke before AutoMate moves to the next key. The default setting of 25 should be acceptable for most applications and system speeds.

Keep Current Foreground Window Focused
Yes\No, Optional - Default NO
MARKUP: STAYFOCUED="YES"

When enabled, specifies that the window that is currently at the front when the step starts should be re-focused before sending each keystroke. This prevents users from changing the focus during execution of the step.

Lock Keyboard and Mouse
Yes\No, Optional - Default NO
MARKUP: LOCKKEYBOARD="YES"

When enabled, specifies that the mouse and keyboard should be locked during the execution of the step so that a user cannot interfere with the keystrokes being sent. The mouse and keyboard are automatically unlocked when the step is finished.

Use DOS Keystrokes
Yes\No, Optional - Default NO
MARKUP: DOS="YES"

This option should be enabled if sending keystrokes to a windowed DOS application as keystrokes are handled differently in DOS.

Encrypt Keystrokes
Yes\No, Optional - Default NO
MARKUP: n/a

When enabled, keystrokes are masked in the task file using 128-bit encryption.

Notes

Usage Notes for Keystrokes when "Simulate Keypress Mode" is Enabled
The following information is only valid when the Method parameter is set to the default "Simulate Keypress" [KEYPRESS]. Since special keys cannot be pasted, this information is not relevant when "Paste characters" [PASTE] is specified.

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, use A. If you want to represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, use ABC. To send a space, simply press the space bar. The plus sign +, caret ^, percent sign %, tilde ~, and parentheses ( ) have special meanings. To specify one of these characters, enclose it within braces. For example, to specify the plus sign, use {+}. Brackets [ ] have no special meaning, but you must enclose them in braces as well, because in other applications, brackets do have a special meaning that may be significant. To send brace characters, use {{} and {}}. To specify characters that aren't displayed when you press a key (such as ENTER or TAB) and keys that represent actions rather than characters, use the codes shown below:

Primary Key Codes
To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the regular key code with one or more of the following codes:

ALT = {ALT}
CTRL = {CTRL}

SHIFT = {SHIFT}

ALTGr = {ALTGR}

Holding Keys Down at the Same Time
To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while "e" and "c" are pressed (e and c keys are "mated"), use {SHIFT}(ec). To specify to hold down SHIFT while "e" is pressed, followed by c without SHIFT, use "{SHIFT}ec".

Repeating Keys

To specify repeating keys, use the form {key code number}. You must put a space between key and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} means press h 10 times.

Other Key Codes

BACKSPACE = {BACKSPACE}, {BS}, or {BKSP}
BREAK = {BREAK}
CAPS LOCK = {CAPSLOCK}
Caps Lock On = {CAPSON}
Caps Lock Off = {CAPSOFF}
DEL = {DELETE} or {DEL}
END = {END}
ENTER = {ENTER} or ~ or (press the enter key)
ESC = {ESC}
HELP = {HELP}
HOME = {HOME}
INS = {INSERT}
NUM LOCK (toggle) = {NUMLOCK}
NUM LOCK On = {NUMLOCKON}
NUM LOCK Off = {NUMLOCKOFF}
PAGE DOWN = {PGDN}
PAGE UP = {PGUP}
PRINT SCREEN = {PRTSC}
SCROLL LOCK (toggle)= {SCROLLLOCK}
SCROLL LOCK Off = {SCROLLLOCKOFF}
SCROLL LOCK On = {SCROLLLOCKON}
TAB = {TAB}
UP ARROW = {UP}
DOWN ARROW = {DOWN}
RIGHT ARROW = {RIGHT}
LEFT ARROW = {LEFT}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Number Pad 0 {NUMPAD0}
Number Pad 1 {NUMPAD1}
Number Pad 2 {NUMPAD2}
Number Pad 3 {NUMPAD3}
Number Pad 4 {NUMPAD4}
Number Pad 5 {NUMPAD5}
Number Pad 6 {NUMPAD6}
Number Pad 7 {NUMPAD7}
Number Pad 8 {NUMPAD8}
Number Pad 9 {NUMPAD9}
Number Pad / {NUMPAD/}
Number Pad * {NUMPAD*}
Number Pad - {NUMPAD-}
Number Pad + {NUMPAD+}
Number Pad . {NUMPAD.}
Separator {NUMPADSEP}
Windows Key {WINKEY}
Popup Menu Key {POPUP}
Press and release ALT {QUICKALT}
Press and release CTRL {QUICKCTRL}
Press and release SHIFT {QUICKSHIFT}

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Example

<AMRUN FILE="notepad.exe">
<AMSENDKEY METHOD="paste">I use Paste Characters for normal text</AMSENDKEY>
<AMSENDKEY>And Simulate Keypress when I want to activate the file menu - like this: {ALT}f</AMSENDKEY>