SendKeys Function
- Last UpdatedFeb 21, 2017
- 2 minute read
Simulates a sequence of key strokes.
Important: The SendKeys() function does not work on 64-bit versions of the Windows operating system.
Syntax
SendKeys sequence;
Parameters
sequence
The sequence of keys strokes to be simulated. A literal string value, message tagname, or string expression.
In addition to regular characters on the keyboard (such as alphanumeric characters) you can also specify control keys as a code:
{BACKSPACE} - Simulates the Backspace key
{BREAK} - Simulates the Break key
{CAPSLOCK} - Simulates the Caps Lock key
{DELETE} - Simulates the Delete key (or {DEL})
{DOWN} - Simulates Arrow Down key
{END} - Simulates the End key
{ENTER} - Simulates the Enter key (or ~)
{ESCAPE} - Simulates the ESC key (or {ESC})
{F1} .. {F12} - Simulate the F1 .. F12 keys
{HOME} - Simulates the Home key
{INSERT} - Simulates the Insert key
{LEFT} - Simulates the Arrow Left key
{NUMLOCK} - Simulates the Num Lock key
{PGDN} - Simulates the Page Down Key
{PGUP} - Simulates the Page Up key
{PRTSC} - Simulates the Print Screen key
{RIGHT} - Simulates the Arrow Right key
{TAB} - Simulates the Tab key
{UP} - Simulates the Up key
+ - Simulates the Shift key
use with parenthesis surrounding the key(s) you want to press in combination with
the Shift key.
^ - Simulates the Ctrl key
use with parenthesis surrounding the key(s) you want to press in combination with
the Ctrl key.
% - Simulates the Alt key
use with parenthesis surrounding the key(s) you want to press in combination with
the Alt key.
Remarks
Use the StartApp and/or ActivateApp() commands to activate another application before sending simulated keys strokes to it.
Example(s)
This script simulates pressing the B key.
SendKeys "b";
This script simulates pressing the key combination Ctrl and P, which can be used to initiate the Printing dialog box in another application.
SendKeys "^(p)";
This script simulates pressing F1 (which may open the help function), pressing the Tab key (which may place the cursor in a search field), entering HAL, and pressing the Enter key (which may initiate the search).
SendKeys "{F1}{TAB}HAL{ENTER}";
This script simulates pressing Ctrl, Shift and the key 1, which is the same as switching to WindowMaker. This powerful combination can be used for developing self-modifying (dynamic) InTouch HMI applications.
SendKeys "^(+(1))";