Skip to main content

1.1. ESSO SendKeys syntax

SendKeys syntax

The sendKeys function aims to perform as the user pressing keystrokes.  Thus, the function SendKeys ("ABC") simulates to press those three letters.

The keystrokes will be done independently of the application that generates them. Thus, it is possible to press keys that change the focused control or even the active application using sendKeys.

To mimic the action of pressing to keys simultaneously, you can make use of modifiers. The available modifiers are listed at the attached table.  So, to send the character ':' you can execute execute sendKeys("+."). This combination will simulate pressing the Shift key along with '.'.  In order to allow a simpler syntax, you can use parentheses to specify more than one key affected by modifiers.  Thus, the function function SendKeys ("+ (hello)")  generates the word HELLO in upper case.

Modifier

Key

@

WINDOWS

+

SHIFT

^

CTRL

%

ALT

It should be noted that this method can not get accented letters as a parameter, but the combination necessary to generate the desired letter.  This method has a big drawback. The combination of keys needed to get a letter can be different depending of the current keyboard layout. So, in order to send arbitrary text characters, it is recommended to use the function function sendText.    

Additionally, the sendKeys function supports this “virtual keystrokes” that do not correspond to a specific key but an actual action do be done:

Tag

Action taken.

VKEY {X}

The virtual code key (VKEY) will be sent.  It is useful to use non-standard keys.

XY {BEEP}

A sound with a frequency X during Y time (in milliseconds).

{DELAY X}

X milliseconds pause.

{DELAY = X}

Make a dealy of X milliseconds between each simulated keystrokes.

{AppActivate WindowTitle}

Bring foreground and activates the application with the specified title.

To send function keys, you can use the following codes:  

Key

Tag

Key

Tag

Backspace

{BACKSPACE} or {BS}

F1

{F1}

Break

{BREAK}

F2

{F2}

CapsLock

{CAPSLOC}

F3

{F3}

Delete

{DELETE} or {DEL}

F4

{F4}

Down arrow

{DOWN}

F5

{F5}

End

{END}

F6

{F6}

Enter

{ENTER} or ~

F7

{F7}

Ex

{ESC}

F8

{F8}

Help

{HELP}

F9

{F9}

Home

{HOME}

F10

{F10}

Lnsert

{INS}

F11

{F11}

Left arrow

{LEFT}

F12

{F12}

Num Lock

{NUMLOCK}

F13

{F13}

Next page

{PGDN}

F14

{F14}

Previous page

{PGUP}

F15

{F15}

Print screen

{PRTSC}

F16

{F16}

Right Arrow

{RIGHT}

^

{CARET}

Scroll Lock

{SCROLL}

~

{Tilde}

Tab

{TAB}

{

{LEFTBRACE}

Up arrow

{UP}

}

{RIGHTBRACE}

+ (Numeric keypad)

{ADD}

(

{LEFTPAREN}

- (Numeric keypad)

{SUBSTRCT}

)

{RIGHTPAREN}

* (Numeric keypad)

{Multiply}

windows (left)

{LWIN} or {RWIN}

/ (Numeric keypad)

{DIVIDE}

windows (right)

{RWIN}

+

{PLUS}

context menu

{APPS}

@

{AT}

 

 

Here are a few small examples :

sendKeys parameter

Effect

{DELAY=50}

1.  Specifies a pause of 50 milliseconds between keystrokes.

@R

2.  Click Windows + R to invoke the run dialog command.

notepad~

3.  Enter notepad and pressed enter.

hello world!

4.  Write "Hello world!".

%ua

5.  Click the button to Alt + u, to show the About dialog box ...

{Delay = 100}

1.  Specifies a pause of 100 milliseconds between keystrokes.

{AppActivate Calculator}

2.  Turn the calculator.

{ESC}

3.  Click ESC to clear the contents.

5*7~

4.  Write 5 * 7 and pressed Enter.

{beep 1000 500}

5.  Makes noise.

^C

6.  Press Control-C to copy the contents.

{appactivate Notepad}

7.  Switch to notepad.

^E

8.  Click to e-control dial all.

{DEL}

9.  Click Delete to delete the contents.

Result of 5 * 7 is:

10.  Writes "The result is 5 * 7".

^V

11.  Click control-v hold the result..

{DELAY=500}{NUMLOCK}{CAPSLOCK}{SCROLL}

1.  Turn numbers, uppercase and scroll on in order.

 

{SCROLL}{CAPSLOCK}{NUMLOCK}

2.  Turn them off in the reverse order.

{DELAY=500}

1.  Specifies a pause of 500 milliseconds between keystrokes.

%?

2.  Click Alt-Space.

{DOWN 5}

3.  Click the down arrow five times.