SendKeys Instruction

Syntax

SendKeys Keys$[, Wait]

Group

Miscellaneous

Description

Sends Keys$ to Windows.

Sandbox

Sandbox mode blocks this instruction.

Parameters

Parameters Description
Keys$ Sends the keys in this string value to Windows. (See the table below.)
Wait If this is not zero, the keys are sent before running the next instruction. If this is omitted or zero, the keys are sent during the following instructions.

 

Key Description
+ Shift modifier key: the following key is a Shift key
^ Ctrl modifier key: the following key is a Control key
% Alt modifier key: the following key is an Alt key
{WindowsHold} Windows modifier key: the following key is a windows key
(keys) Modifiers apply to all keys
~ Sends Enter key
k Sends k Key (k is any single char)
K Sends Shift k Key (K is any capital letter)
{special n} Sends Special key (n is an optional repeat count)
{mouse x,y} Sends Mouse key (x,y is an optional screen position)
{k} Sends k Key (any single character)
{K} Sends Shift k Key (any single character)
{Cancel} Sends Break Key
{Esc} Sends Escape Key
{Escape} Sends Escape Key
{Enter} Sends Enter Key
{Menu} Sends Menu Key (Alt)
{Windows} Sends Windows Key (logo key)
{Help} Sends Help Key (?)
{Prtsc} Sends Print Screen Key
{Print} Sends Print
{Execute} Sends ?
{Tab} Sends aTab Key
{Pause} Sends Pause Key
{Tab} Sends Tab Key
{BS} Sends Back Space Key
{BkSp} Sends Back Space Key
{BackSpace} Sends Back Space Key
{Del} Sends Delete Key
{Delete} Sends Delete Key
{Ins} Sends Insert Key
{Insert} Sends Insert Key
{Left} Sends Left Arrow Key
{Right} Sends Right Arrow Key
{Up} Sends Up Arrow Key
{Down} Sends Down Arrow Key
{PgUp} Sends Page Up Key
{PgDn} Sends Page Down Key
{Home} Sends Home Key
{End} Sends End Key
{Select} Sends ?
{Clear} Sends Num Pad 5 Key
{Pad0..9} Sends Num Pad 0-9 Keys
{Pad*} Sends Num Pad * Key
{Pad+} Sends Pad + Key
{PadEnter} Sends Num Pad Enter
{Pad.} Sends Num Pad . Key
{Pad-} Sends Num Pad - Key
{Pad/} Sends Num Pad / Key
{F1..24} Sends F1 to F24 Keys

Mouse

Mouse movement and button clicks:

  • {Move x,y} - Moves the mouse to (x,y).
  • {ClickLeft x,y} - Moves the mouse to (x,y) and clicks the left mouse button. (This is the same as {DownLeft x,y}{UpLeft}.)
  • {DoubleClickLeft x,y} - Moves the mouse to (x,y) and clicks the left mouse button. (This is NOT the same as {ClickLeft x,y}{ClickLeft}.)
  • {DownLeft x,y} - Moves the mouse to (x,y) and pushes the left mouse button down.
  • {UpLeft x,y} - Moves the mouse to (x,y) and releases the left mouse button.
  • {...Middle x,y} - Similarly named keys for the middle mouse button.
  • {...Right x,y} - Similarly named keys for the right mouse button.

The x,y values are screen pixel locations, where (0,0) is in the upper-left corner. In all cases, the x,y is optional. If omitted, the previous mouse position is used.

Example


Sub Main
    SendKeys "%S"     ' send Alt-S (Search)
    SendKeys "GoTo~~" ' send G o T o {Enter} {Enter}
End Sub

See also

AppActivate, KeyName, Shell( )