AutoIt Send Function
How to use the AutoIt send function to send keystrokes to the currently active window.
Edited: 2020-08-25 16:56
The AutoIt Send function is used to simulate keyboard input, sending keystrokes to the currently window.
Certain characters have special meaning, and are used to send special keys, such as CTRL (^) or SHIFT (+). To press the SHIFT and "t" key at the same time, use the plus sign, like this:
Send("+t") ; Results in uppercase "T"
To ignore special characters, and instead send the raw data, set the second parameter of send():
Send("+t", 1) ; Results in uppercase "+t"
If you prefer, you can also use a keycode to send a specific key:
Send("{LWINDOWN}") ; Sends the Left Windows Key
More examples
Holding down the "a" key:
Send("{a down}")
Send a key multiple times:
Send("{ENTER 4}") ; Sends ENTER 4 times.
Toggle CapsLock, NumLock, and ScrollLock on/off:
Send("{NumLock on}") ; Use on || off to toggle
Send("{CapsLock on}") ; Use on || off to toggle
Send("{ScrollLock toggle}") ;Toggles the state of ScrollLock
Parameters
The send function will accept two parameters. The first is the keys to send, the second is an optional flag value.
Keys | Keys, kay combination, or sequence of keys to send. |
Flag | 1. Ignore Special Characters (sending raw text) – 2. Special Characters are not ignored.. |
Send Command Reference
Special Keys.
! | ALT – I.e. [!a] (would send ALT+a) |
+ | SHIFT – I.e. [+ab+cd] (would result in AbCd) |
^ | CONTROL – I.e. [^2] (would send CTRL+2) |
# | WINDOWS KEY – I.e. [#r] (would press WKEY+r – opening the run command in windows) |
Keycode Reference
{SPECIAL CHARACTER} | Will escape the character if flag is set to 0 – I.e. [{{}abc{}}] (Results in: {abc}) |
{KAY 3} | Presses the KEY for the given count – I.e. [{a 5}] or [{SPACE 3}] |
{SPACE} | SPACE |
{TAB} | TAB |
{ENTER} | ENTER |
{ALT} | ALT |
{BACKSPACE} or {BS} | BACKSPACE |
{DELETE} or {DEL} | DELETE |
{UP} | UP Arrow |
{RIGHT} | RIGHT Arrow |
{DOWN} | DOWN Arrow |
{LEFT} | LEFT Arrow |
{HOME} | HOME |
{END} | END |
{ESCAPE} or {ESC} | ESCAPE |
{INSERT} or {INS} | INSERT |
{PGUP} | PAGE UP |
{PGDN} | PAGE DOWN |
{F1} to {F12} | The F keys |
{PRINTSCREEN} | PRINT SCREEN |
{LWIN} | LEFT WINDOWS KEY |
{RWIN} | RIGHT WINDOWS KEY |
{NUMLOCK on} | NUMLOCK – on/off |
{CAPSLOCK off} | CAPSLOCK – on/off |
{SCROLLLOCK on} | SCROLLLOCK – on/off |
{BREAK} | For CTRL+BREAK processing |
{PAUSE} | PAUSE |
{APPSKEY} | WINDOWS APP |
{LALT} | LEFT ALT |
{RALT} | RIGHT ALT |
{LCTRL} | LEFT CTRL |
{RCTRL} | RIGHT CTRL |
{LSHIFT} | LEFT SHIFT |
{RSHIFT} | RIGHT SHIFT |
{SLEEP} | SLEEP |
The Numpad Keys.
{NUMPAD0} - {NUMPAD9} | DIGITS |
{NUMPADMULT} | MULTIPLY |
{NUMPADSUB} | SUBTRACT |
{NUMPADADD} | ADD |
{NUMPADDIV} | DIVIDE |
{NUMPADDOT} | PERIOD |
{NUMPADENTER} | ENTER on the numpad |
UP and DOWN Keycodes.
{ALTDOWN} | Holds ALT down until {ALTUP} is sent. |
{SHIFTDOWN} | Holds SHIFT down until {SHIFTUP} is sent. |
{CTRLDOWN} | Holds CTRL down until {CTRLUP} is sent. |
{LWINDOWN} | Holds LEFT WINDOWS KEY down until {LWINUP} is sent. |
{RWINDOWN} | Holds RIGHT WINDOWS KEY down until {RWINUP} is sent. |
Links
- Send - autoitscript.com
Tell us what you think: