SendKeys
Use SendKeys to send keystrokes to another application. This function mimics the behavior of a human sitting at the keyboard, entering keystrokes.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "5{+}"
WScript.Sleep 500
WshShell.SendKeys "10"
WScript.Sleep 1000
WshShell.SendKeys "="
WScript.Sleep 250
Note: You can send more than 1 key at a time.
WshShell.SendKeys "ABC" ' Sends the keystrokes "ABC"
WshShell.SendKeys "5{+}" ' Sends the keystrokes "5" and the "+" key
The Following "Special Characters" must be enclosed in "Curly Bracers"
| + |
{+} |
| ^ |
{^} |
| % |
{%} |
| ~ |
{~} |
| { |
{{} |
| } |
{}} |
The Ctrl, Alt and Shift Characters
To send the SHIFT key followed by the "d" and "e" you would enter +(de)
To send a SHIFT-d followed by a Normal e, you would enter +de
| Key to Simulate |
VBScript |
BACKSPACE |
{BACKSPACE}, {BS}, or {BKSP} |
BREAK |
{BREAK} |
CAPS LOCK |
{CAPSLOCK} |
DEL or DELETE |
{DELETE} or {DEL} |
DOWN ARROW |
{DOWN} |
END |
{END} |
ENTER |
{ENTER} or ~ |
ESC |
{ESC} |
HELP |
{HELP} |
HOME |
{HOME} |
INS or 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 |
{F1} |
F2 |
{F2} |
F3 |
{F3} |
F4 |
{F4} |
F5 |
{F5} |
F6 |
{F6} |
F7 |
{F7} |
F8 |
{F8} |
F9 |
{F9} |
F10 |
{F10} |
F11 |
{F11} |
F12 |
{F12} |
F13 |
{F13} |
F14 |
{F14} |
F15 |
{F15} |
F16 |
{F16} |
Become a Member
Start learning about VBScript right now!
Become a Member and begin downloading our VBScript Videos Immediately!
These VBScript Videos are from our VBScript Product
|