Tip Send Keys and Reserved Characters

Some characters have a special meaning when used with the SendKeys statement. These keys are: plus sign (+), caret (A), tilde (~), and parentheses (). To send these characters to another application, you must enclose them in braces {}. To send the braces, enter {{} and {}}.

The second argument of the SendKeys statement is optional. Wait is a logical value that is true or false. If false (default), Visual Basic returns to the procedure immediately upon sending the keystrokes. If wait is true, Visual Basic returns to the procedure only after the sent keystrokes have been executed.

To send characters that aren't displayed when you press a key, use the codes in Table 9-3. Remember to enclose these codes in quotes. For example:

SendKeys "{BACKSPACE}"

Table 9-3: Keycodes used with the SendKeys statement

SendKeys "{BACKSPACE}"

Table 9-3: Keycodes used with the SendKeys statement

Key

Code

Key

Code

Backspace

{BACKSPACE}

Scroll Lock

{SCROLLLOCK}

{BS}

Tab

{TAB}

{BKSP}

Up Arrow

{UP}

Break

{BREAK}

F1

{F1}

Caps Lock

{CAPSLOCK}

F2

{F2}

Delete

{DELETE}

F3

{F3}

{DEL}

F4

{F4}

Down Arrow

{DOWN}

F5

{F5}

End

{END}

F6

{F6}

Enter

{ENTER}

F7

{F7}

~

F8

{F8}

Esc

{ESC}

F9

{F9}

Help

{HELP}

F10

{F10}

Home

{HOME}

F11

{F11}

Insert

{INSERT}

F12

{F12}

{INS}

F13

{F13}

Left Arrow

{LEFT}

F14

{F14}

Num Lock

{NUMLOCK}

F15

{F15}

Page Down

{PGDN}

F16

{F16}

Page Up

{PGUP}

Shift

+

Print Screen

{PRTSC}

Ctrl

A

Right Arrow

{RIGHT}

Alt

<V %

0 0

Post a comment