Simulates a user pressing one or more keys in the active form.
Simulates a user pressing one or more keys in the active form.
| Visual Basic |
|---|
Public Sub SendKeys( _ ByVal Text As String _ ) |
Each key is represented by one or more characters.
A for Text.
ABC for Text.
{}). For example, to send the plus sign, use {+}. Brackets ([ ]) have no special meaning in SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use {{} and {}}. To send characters that aren't displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes shown below:
| Key | Code |
|---|---|
| Backspace | {BACKSPACE}, {BS}, or {BKSP} |
| Break | {BREAK} |
| Caps Lock | {CAPSLOCK} |
| Delete | {DELETE} or {DEL} |
| Down Arrow | {DOWN} |
| End | {END} |
| Enter | {ENTER} |
| Esc | {ESC} |
| Help | {HELP} |
| Home | {HOME} |
| Insert | {INSERT} or {INS} |
| Left Arrow | {LEFT} |
| Num Lock | {NUMLOCk} |
| Page Down | {PGDN} |
| Page Up | {PGUP} |
| Right Arrow | {RIGHT} |
| Scroll Lock | {SCROLLLOCK} |
| Tab | {TAB} |
| Up Arrow | {UP} |
| F1, F2, F3... | {F1}, {F2}, {F3}... |
To specify key combinations with any of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:
| Key | Code |
|---|---|
| Shift | {+} |
| Ctrl | {^} |
| Alt | {%} |
To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify holding down SHIFT while E and C are pressed, use " +(EC)". To specify holding down SHIFT, while E is pressed, followed by C without SHIFT, use " +EC".
Warning