Sends a keystroke (or string of keystrokes) to a window as if they were typed on the keyboard. The window receives input focus and is brought to the foreground.
This function is a blocking function. It blocks the calling Cicode task until the operation is complete.
Syntax
SendKeys(sTitle, sKeys)
sTitle:
The title (caption) of the destination window.
sKeys:
The key (or keys) to send to sTitle.
|
Key |
Code |
|
Backspace |
{backspace} or {bs} or{bksp} |
|
Break |
{break} |
|
Caps Lock |
{capslock} |
|
Clear |
{clear} |
|
Del |
{delete} or {del} |
|
End |
{end} |
|
Enter |
{enter} or ~ |
|
Esc |
{escape} or {esc} |
|
Help |
{help} |
|
Home |
{home} |
|
Insert |
{insert} |
|
Num Lock |
{numlock} |
|
Page Down |
{pgdn} |
|
Page Up |
{pgup} |
|
Print Screen |
{prtsc} |
|
Scroll Lock |
{scrolllock} |
|
Tab |
{tab} |
|
Up Arrow |
{up} |
|
Down Arrow |
{down} |
|
Right Arrow |
{right} |
|
Left Arrow |
{left} |
|
F1 |
{f1} |
|
F2 |
{f2} |
|
F3 |
{f3} |
|
F4 |
{f4} |
|
F5 |
{f5} |
|
F6 |
{f6} |
|
F7 |
{f7} |
|
F8 |
{f8} |
|
F9 |
{f9} |
|
F10 |
{f10} |
|
F11 |
{f11} |
|
F12 |
{f12} |
Key | Code |
Shift | + |
Ctrl | ^ |
Alt | % |
To specify that Shift, Ctrl, and/or Alt are held down while several keys are pressed, enclose the keys in parentheses. For example, to hold down the Shift key while sending E then C, use +(EC). To hold down Shift while sending E, followed by C without the Shift key, use +EC. To specify repeating keys, use the form {key number}. For example, {left 42} means send the left arrow key 42 times. Be aware that you need to leave a space between the key and number.
Return Value
0 (zero) if successful, otherwise an error code is returned.
Related Functions
Example
SendKeys("Untitled - Notepad", "abc");
// Send the key sequence "abc" to the Notepad application
See Also
Published June 2018