SendKeys statement (LotusScript® Language)
Enters keystrokes in the active window as if they were entered from the keyboard.
SendKeys is not supported on Macintosh and UNIX™ platforms and is not supported in Domino® and Notes®.
Syntax
SendKeys string [ , processNow ]
string
Any string expression, specifying a sequence of keystrokes to be sent to the active window.
To repeat a keystroke in string, use the code {key count}, where key is the keystroke to repeat, and count is the number of times to repeat it. For example, "{RIGHT 3}" represents pressing the Right Arrow key three times.
Include a space between key and count; otherwise {key count} may be interpreted as a function key specification. For example, "{F 4}" represents pressing the letter F four times, but "{F4}" represents pressing the function key F4.
processNow
Optional. Any numeric value. A nonzero value is interpreted as TRUE; a zero (0) is interpreted as FALSE.
- If processNow is TRUE, script execution does not continue until after all characters in string have been processed by the active window.
- If processNow is FALSE, script execution continues immediately, whether or not string has been fully processed.
The default value of processNow is FALSE. You will usually want to specify TRUE for processNow.
Usage
The SendKeys statement is not legal at the module level, for example, in a Domino® design element. In a Windows™ environment, create a WScript.Shell object and use its SendKeys method.
To send an ordinary keyboard key or sequence of keys, such as A or 8 or DIR, simply include the character(s) in string.
To send non-printing keyboard keys, such as Tab or Backspace, or keys that perform actions in the active window, such as Page Up, use the key code from the following table in string.
Key |
Code |
---|---|
Backspace |
{BS} or {BKSP} or {BACKSPACE} |
Break |
{BREAK} |
Caps Lock |
{CAPSLOCK} |
Clear |
{CLEAR} |
Del |
{DEL} or {DELETE} |
Down arrow |
{DOWN} |
End |
{END} |
Enter |
~ or {ENTER} |
Esc |
{ESC} or {ESCAPE} |
Help |
{HELP} |
Home |
{HOME} |
Ins |
{INSERT} |
Left arrow |
{LEFT} |
Num Lock |
{NUMLOCK} |
Pg Dn |
{PGDN} |
Pg Up |
{PGUP} |
Right arrow |
{RIGHT} |
Scroll Lock |
{SCROLLLOCK} |
Tab |
{TAB} |
Up arrow |
{UP} |
Function keys |
{F1} to {F16} |
To include a character from the following table in string, enclose it in braces as shown.
Character |
Code |
---|---|
Brace |
{{} or {}} |
Bracket |
{[} or {]} |
Caret |
{^} |
Parenthesis |
{(} or {)} |
Percent sign |
{%} |
Plus sign |
{+} |
Tilde |
{~} |
The following table shows how to designate keys pressed in combination with Alt, Ctrl, or Shift.
Combination key |
Code |
Example |
---|---|---|
Alt |
% |
%{F4} represents Alt+F4 |
Ctrl |
^ |
^{F4} represents Ctrl+F4 |
Shift |
+ |
+{F4} represents Shift+F4 |
To apply a combination key to a sequence of keys, enclose the sequence in parentheses. For example, +(xy) holds down the Shift key for both x and y. It is equivalent to +x+y.
SendKeys cannot send keystrokes to a window that is not a Windows™ Presentation Manager program, and cannot send the Print Scrn key to any program.
SendKeys generates an "Illegal function call" error if string contains any of the following elements:
- An unmatched parenthesis
- An illegal key code
- An illegal repeat count
- Too many characters
Note that SendKeys is often useful after Shell, to send keystrokes to the program that Shell started. Remember that Shell does not guarantee that the program is loaded before executing the statements that follow it.