Sends keystrokes to the active window as if typed at the keyboard using the optional delay between keystrokes (default is 50 ms and should be OK for most uses).
Keystrokes to be send to a window having input focus
[Optional] delay between keys strokes
The keystrokes to send are specified in KEYS. There are several characters that have special meaning. This allows sending control codes and modifiers:
~ means ENTER
+ means SHIFT
^ means CTRL
% means ALT
The parens allow character grouping. You may group several characters, so that a specific keyboard modifier applies to all of them.
E.g. SendKeys("ABC") is equivalent to SendKeys("+(abc)")
The curly braces are used to quote special characters (SendKeys("{+}{{}") sends a '+' and a '{'). You can also use them to specify certain named actions:
Name | Action |
---|---|
{BACKSPACE} | Backspace |
{BS} | Backspace |
{BKSP} | Backspace |
{BREAK} | Break |
{CAPS} | Caps Lock |
{DELETE} | Delete |
{DOWN} | Down arrow |
{END} | End |
{ENTER} | Enter (same as ~) |
{ESCAPE} | Escape |
{HELP} | Help key |
{HOME} | Home |
{INSERT} | Insert |
{LEFT} | Left arrow |
{NUMLOCK} | Num lock |
{PGDN} | Page down |
{PGUP} | Page up |
{PRTSCR} | Print screen |
{RIGHT} | Right arrow |
{SCROLL} | Scroll lock |
{TAB} | Tab |
{UP} | Up arrow |
{PAUSE} | Pause |
{F1} | Function Key 1 |
... | ... |
{F24} | Function Key 24 |
{SPC} | Spacebar |
{SPACE} | Spacebar |
{SPACEBAR} | Spacebar |
{LWI} | Left Windows Key |
{RWI} | Right Windows Key |
{APP} | Open Context Menu Key |
All these named actions take an optional integer argument, like in {RIGHT 5}. For all of them, except PAUSE, the argument means a repeat count. For PAUSE it means the number of milliseconds SendKeys should pause before proceeding.
In this implementation, SendKeys always returns after sending the keystrokes. There is no way to tell if an application has processed those keys when the function returns.