SendKeys Instruction
Syntax
Group
Description
Send Keys$ to Windows.
Parameter | Description |
---|---|
Keys$ | Send the keys in this string value to Windows. (Refer to table below.) |
Wait | If this is not zero then the keys are sent before executing the next instruction. If this is omitted or zero then the keys are sent during the following instructions. |
Key | Description |
---|---|
+ | Shift modifier key: the following key is a shifted key |
^ | Ctrl modifier key: the following key is a control key |
% | Alt modifier key: the following key is an alt key |
(keys) | Modifiers apply to all keys |
~ | Send Enter key |
k | Send k Key (k is any single char) |
K | Send Shift k Key (K is any capital letter) |
{special n} | special key (n is an optional repeat count) |
{mouse x,y} | mouse key (x,y is an optional screen position) |
{k} | Send k Key (any single char) |
{K} | Send Shift k Key (any single char) |
{Cancel} | Send Break Key |
{Esc} | Send Escape Key |
{Escape} | Send Escape Key |
{Enter} | Send Enter Key |
{Menu} | Send Menu Key (Alt) |
{Help} | Send Help Key (?) |
{Prtsc} | Send Print Screen Key |
{Print} | Send |
{Execute} | Send ? |
{Tab} | Send |
{Pause} | Send Pause Key |
{Tab} | Send Tab Key |
{BS} | Send Back Space Key |
{BkSp} | Send Back Space Key |
{BackSpace} | Send Back Space Key |
{Del} | Send Delete Key |
{Delete} | Send Delete Key |
{Ins} | Send Insert Key |
{Insert} | Send Insert Key |
{Left} | Send Left Arrow Key |
{Right} | Send Right Arrow Key |
{Up} | Send Up Arrow Key |
{Down} | Send Down Arrow Key |
{PgUp} | Send Page Up Key |
{PgDn} | Send Page Down Key |
{Home} | Send Home Key |
{End} | Send End Key |
{Select} | Send ? |
{Clear} | Send Num Pad 5 Key |
{Pad0..9} | Send Num Pad 0-9 Keys |
{Pad*} | Send Num Pad * Key |
{Pad+} | Send Pad + Key |
{PadEnter} | Send Num Pad Enter |
{Pad.} | Send Num Pad . Key |
{Pad-} | Send Num Pad - Key |
{Pad/} | Send Num Pad / Key |
{F1..24} | Send F1 to F24 Keys |
Mouse
Mouse movement and button clicks:
• {Move x,y} - move the mouse to (x,y)
• {ClickLeft x,y} - move the mouse to (x,y) and click the left button. (This is the same as {DownLeft x,y}{UpLeft}.)
• {DoubleClickLeft x,y} - move the mouse to (x,y) and click the left button. (This is NOT the same as {ClickLeft x,y}{ClickLeft}.)
• {DownLeft x,y} - move the mouse to (x,y) and push the left button down.
• {UpLeft x,y} - move the mouse to (x,y) and release the left button.
• similarly named keys for the middle and right mouse buttons.
The x,y values are screen pixel location (0,0) is in the upper-right. In all cases the x,y is optional. If omitted the previous mouse position is used.
See Also: AppActivate, KeyName, Shell( ).
Example
Sub Main
SendKeys "%S" ' send Alt-S (Search)
SendKeys "GoTo~~" ' send G o T o {Enter} {Enter}
End Sub
Note
In general, SendKeys cannot be used with characters higher than ASCII 127. Use SendDragonKeys instead. SendDragonKeys supports some characters that SendKeys does not support. For a table listing the names of nonprinting keys and the codes to use in SendDragonKeys see the topic: Key names for SendDragonKeys.