티스토리 뷰

[VBS]  WshShell.SendKeys

 

WshShell.SendKeys

Send one or more keystrokes to the active window as if they were typed at the keyboard. This method is similar to the VB SendKeys method.

WshShell.SendKeys "Character_string_and/or_SendKeys"

Most ASCII characters can be represented simply by the character itself. 
E.g, the key sequence FRED can be represented by "FRED". 
Some special keys, such as the control keys, function keys etc are encoded in a string enclosed by {braces} 
See the table below

Key/CharacterSendKeyDescription

~ {~} Send a tilde (~)
! {!} Send an exclamation point (!)
^ {^} Send a caret (^)
+ {+} Send a plus sign (+)
Backspace {BACKSPACE} or {BKSP} or {BS} Send a Backspace keystroke
Break {BREAK} Send a Break keystroke
Caps Lock {CAPSLOCK} Press the Caps Lock Key (toggle on or off)
Clear {CLEAR} Clear the field
Delete {DELETE} or {DEL} Send a Delete keystroke
Insert {INSERT} or {INS} Send an Insert keystroke
Cursor control arrows {LEFT} / {RIGHT} / {UP} / {DOWN} Send a Left/Right/Up/Down Arrow
End {END} Send an End keystroke
Enter {ENTER} or ~ Send an Enter keystroke
Escape {ESCAPE} Send an Esc keystroke
F1 through F16 {F1} through {F16} Send a Function keystroke
Help {HELP} Send a Help keystroke
Home {HOME} Send a Home keystroke
Numlock {NUMLOCK} Send a Num Lock keystroke
Page Down
Page Up
{PGDN}
{PGUP}
Send a Page Down or Page Up keystroke
Print Screen {PRTSC} Send a Print Screen keystroke
Scroll lock {SCROLLLOCK} Press the Scroll lock Key (toggle on or off)
TAB {TAB} Send a TAB keystroke

To specify keys combined with any combination of SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following:

For SHIFT prefix with + For CTRL prefix with ^ For ALT prefix with %

Example

' Open notepad Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "notepad.exe", 9 ' Give Notepad time to load WScript.Sleep 500 ' Type in Hello World WshShell.SendKeys "Hello World!" WshShell.SendKeys "{ENTER}" ' Add the date WshShell.SendKeys "{F5}"

댓글

파트너스 활동을 통해 일정액의 수수료를 제공받을 수 있음



Total
Today
Yesterday
최근에 달린 댓글