티스토리 뷰
[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}"
'Computer > VBS (Visual Basic Script)' 카테고리의 다른 글
[VBS] Microsoft Edge 실행 및 복합 동작 시나리오 (0) | 2020.03.10 |
---|---|
[VBS] SendKeys Input Keycode (0) | 2020.03.09 |
[VBS] Space 포함된 파일 실행하기 (0) | 2019.06.11 |
[VBS] Process Find and Activate (0) | 2019.05.23 |
VB스크립트란 (VBS란) (0) | 2019.05.22 |