Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Application Server

SendKeys()

  • Last UpdatedJun 07, 2022
  • 2 minute read

Sends keystrokes to an application. To the receiving application, the keys appear to be entered from the keyboard. You can use SendKeys() within a script to enter data or send commands to an application. Most keyboard keys can be used in a SendKeys() statement. Each key is represented by one or more characters, such as A for the letter A or {ENTER} for the Enter key.

Category

Miscellaneous

Syntax

SendKeys( KeySequence );

Parameter

KeySequence

Any key sequence or a string attribute.

Remarks

To specify more than one key, concatenate the codes for each character. For example, to specify the dollar sign ($) key followed by a (b), enter $b.

The following lists the valid send key codes for unique keyboard keys:

Key

Code

BACKSPACE

{BACKSPACE}or {BS}

BREAK

{BREAK}

CAPSLOCK

{CAPSLOCK}

DELETE

{DELETE} or {DEL}

DOWN

{DOWN}

END

{END}

ENTER

{ENTER} or tilde (~ )

ESCAPE

{ESCAPE} or {ESC}

F1...F12

{F1}...{F12}

HOME

{HOME}

INSERT

{INSERT}

LEFT

{LEFT}

NUMLOCK

{NUMLOCK}

PAGE DOWN

{PGDN}

PAGE UP

{PGUP}

PRTSC

{PRTSC}

RIGHT

{RIGHT}

TAB

{TAB}

UP

{UP}

HOME

{HOME}

Special keys (SHIFT, CTRL, and ALT) have their own key codes:

Key

Code

SHIFT

+ (plus)

CTRL

^ (caret)

ALT

% (percent)

Enhancements to the Microsoft Hardware Abstraction Layer in Windows prevents the SendKeys() function from operating on some computers.

Examples

To use two special keys together, use a second set of parentheses. The following statement holds down the CTRL key while pressing the ALT key, followed by p:

SendKeys ("^(%(p))");

Commands can be preceded by the ActivateApp() command to direct the keystrokes to the proper application.

The following statement gives the computer focus to Calculator and sends the key combination 1234:

ActivateApp("Calculator");

SendKeys("^(1234)");

In This Topic
TitleResults for “How to create a CRG?”Also Available in