Command: SendKeys

Previous  Next |  Direct link to this topic

Go to list of all Commands

Syntax: SendKeys(<dataToSend>);

 

Warning: From experience we know that in 99% of all cases use of Sleep and SendKeys are the wrong approach to a problem/scenario and there are more likely a better approach to your problem. This video explains this in more details

 

Simulate keystrokes on the keyboard.

The plus sign (+), caret (^), percentage sign (%), tilde (~), and parentheses ( ) have special meanings in SendKeys. To send one of these characters, enclose it within braces ( {}). For example, to send the plus sign, use {+}. Brackets ([ ]) have no special meaning in SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}.

To send characters that are not displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes shown below:

Key

Code

Backspace

{BACKSPACE}, {BS}, or {BKSP}

Break

{BREAK}

Caps Lock

{CAPSLOCK}

Delete

{DELETE} or {DEL}

Down Arrow

{DOWN}

End

{END}

Enter

{ENTER}

Esc

{ESC}

Help

{HELP}

Home

{HOME}

Insert

{INSERT} or {INS}

Left Arrow

{LEFT}

Num Lock

{NUMLOCk}

Page Down

{PGDN}

Page Up

{PGUP}

Right Arrow

{RIGHT}

Scroll Lock

{SCROLLLOCK}

Tab

{TAB}

Up Arrow

{UP}

F1, F2, F3...

{F1}, {F2}, {F3}...

To specify key combinations with any of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:

Key

Code

Shift

{+}

Ctrl

{^}

Alt

{%}

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 holding down SHIFT while E and C are pressed, use " +(EC)". To specify holding down SHIFT, while E is pressed, followed by C without SHIFT, use " +EC".

Samples: SendKeys(abc); will enter abc in current field, SendKeys(^P); will initiate the print-dialog while SendKeys(+{F2}) will activate current item's formatted search.

TIP: You can use dynamic data from the current window in the value to set using $[$item.column.type].

TIP: You can make the value to set come from an SQL-sentence if you start it with SQL:<SQL-statement>.

TIP: You can make the value to set come from an SQL-sentence if you start it with SQL_INVARIANT:<SQL-statement>. SQL invariant is used to ensure that decimal numbers are returned in the correct format depending on your system

 


Similar/Related Commands:
- Sleep