Use the SendKeys method to send keystrokes to applications or controls.
Most keyboard characters are represented by a single keystroke.
Some keyboard characters are made up of combinations of keystrokes (CTRL, SHIFT, HOME)
To send a single keyboard character, send the character itself as the string argument.
For example, to send the letter x, send the string argument "x", to send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time.
To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning.
To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one. Some keystrokes do not generate characters (such as ENTER and TAB).
Some keystrokes represent actions (such as BACKSPACE and BREAK).
To send these kinds of keystrokes, send the arguments shown in the following table:
To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, crete a compound string argument that represents the keystroke combination. You do this by preceding the regular keytroke with one or more of the following special characters:
You can use SendKeys to send more than one keystroke at a time.
To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:
| Key | Argument |
|---|---|
| plus sign | "+" |
| caret | "^" |
| percent sign | "%" |
| tilde | "~" |
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning.
To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one. Some keystrokes do not generate characters (such as ENTER and TAB).
Some keystrokes represent actions (such as BACKSPACE and BREAK).
To send these kinds of keystrokes, send the arguments shown in the following table:
| Key | Argument |
|---|---|
| BACKSPACE | {BACKSPACE}, {BS}, or {BKSP} |
| BREAK | {BREAK} |
| CAPS LOCK | {CAPSLOCK} |
| DELETE | {DELETE} or {DEL} |
| DOWN ARROW | {DOWN} |
| END | {END} |
| ENTER | {ENTER} or ~ |
| ESC | {ESC} |
| HELP | {HELP} |
| HOME | {HOME} |
| INSERT | {INSERT} or {INS} |
| LEFT ARROW | {LEFT} |
| NUM LOCK | {NUMLOCK} |
| PAGE DOWN | {PGDN} |
| PAGE UP | {PGUP} |
| PRINT SCREEN | {PRTSC} |
| RIGHT ARROW | {RIGHT} |
| SCROLL LOCK | {SCROLLLOCK} |
| TAB | {TAB} |
| UP ARROW | {UP} |
| F1 ... F16 | {F1} ... {F16} |
| Left Windows Key | {LWIN} |
| Right Windows Key | {RWIN} |
To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, crete a compound string argument that represents the keystroke combination. You do this by preceding the regular keytroke with one or more of the following special characters:
| Key | Argument |
|---|---|
| SHIFT | + |
| CTRL | ^ |
| ALT | % |
