Interacting with the Screen

The main objective to most scripts is to pull data from the phone book and send key strokes to a screen in a third-party application.

SENDKEYS Keys, Wait

Keys is a variable or string literal of key strokes to send to the active application.

If Wait <> 0, keystrokes must be processed before control is returned to the procedure. Otherwise, control is returned to the procedure immediately after the keys are sent.

If the Caps Lock key is on, it is temporarily turned off during the send keys.

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" for keytext. 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" for keytext.

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) have special meanings to SendKeys. To specify one of these characters, enclose it inside braces. For example, to specify the plus sign, use {+}. 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:

KeyCode
Backspace{BACKSPACE} or {BS} or {BKSP}
Break{BREAK}
Caps Lock{CAPSLOCK}
Clear{CLEAR}
Del{DELETE} or {DEL}
Down Arrow{DOWN}
End{END}
Enter~
Esc{ESCAPE} or {ESC}
Help{HELP}
Home{HOME}
Ins{INSERT}
Left Arrow{LEFT}
Num Lock{NUMLOCK}
Page Down{PGDN}
Page Up{PGUP}
Print Screen{PRTSC}
Right Arrow{RIGHT}
Scroll Lock{SCROLLLOCK}
Tab{TAB}
Up Arrow{UP}
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}

To specify keys combined with any combination of Shift, Ctrl, and Alt keys, precede the regular key code with one or more of the following codes:

KeyCode
Shift+
Control^
Alt%

To specify that Shift, Ctrl, and/or Alt should be held down while several other keys are pressed, enclose the keys' code in parentheses. For example, to have the Shift key held down while E and C are pressed, use "+(EC)". To have Shift held down while E is pressed, followed by C being pressed without Shift, use "+EC".

To specify repeating keys, use the form {key 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.

To highlight all text in a text box, use Ctrl-a (not Ctrl-A). The command is

SENDKEYS "^a", 1

Note: SendKeys can't send keystrokes to an application that is not designed to run in Microsoft Windows. Sendkeys also can't send the Print Screen (PRTSC) key to any application.

Note: When including {CAPSLOCK}, {NUMLOCK}, or {SCROLLLOCK}, the key is temporarily toggled for the duration of the send keys.

Sending Variables

To include a script variable as part of the keys to send, use {VAR varname}. For example, SENDKEYS "Hello {VAR FirstName}" sends "Hello Bill" if FirstName = "Bill".

SENDKEYS_LITERAL Keys, Wait

This is exactly the same as SendKeys, except, before sending the string, all special characters %^+{} are escaped by surrounding them with {}.

SENDKEYS_REPEAT Keys , Wait, RepeatInt

This is exactly the same as SendKeys, except it sends the keys RepeatInt times.

© 1991-2024 - Baseline Data Systems, Inc.