vbs sendKeys Virtual-Key Codes 十六进制符号


Constants

(0x01)
Left mouse button

(0x02)
Right mouse button

(0x03)
Control-break processing

(0x04)
Middle mouse button (three-button mouse)

(0x05)
Windows 2000/XP: X1 mouse button

(0x06)
Windows 2000/XP: X2 mouse button

(0x07)
Undefined

(0x08)
BACKSPACE key

(0x09)
TAB key

(0x0A-0B)
Reserved

(0x0C)
CLEAR key

(0x0D)
ENTER key

(0x0E-0F)
Undefined

(0x10)
SHIFT key

(0x11)
CTRL key

(0x12)
ALT key

(0x13)
PAUSE key

(0x14)
CAPS LOCK key

(0x15)
Input Method Editor (IME) Kana mode

(0x15)
IME Hanguel mode (maintained for compatibility; use VK_HANGUL)

(0x15)
IME Hangul mode

(0x16)
Undefined

(0x17)
IME Junja mode

(0x18)
IME final mode

(0x19)
IME Hanja mode

(0x19)
IME Kanji mode

(0x1A)
Undefined

(0x1B)
ESC key

(0x1C)
IME convert

(0x1D)
IME nonconvert

(0x1E)
IME accept

(0x1F)
IME mode change request

(0x20)
SPACEBAR

(0x21)
PAGE UP key

(0x22)
PAGE DOWN key

(0x23)
END key

(0x24)
HOME key

(0x25)
LEFT ARROW key

(0x26)
UP ARROW key

(0x27)
RIGHT ARROW key

(0x28)
DOWN ARROW key

(0x29)
SELECT key

(0x2A)
PRINT key

(0x2B)
EXECUTE key

(0x2C)
PRINT SCREEN key

(0x2D)
INS key

(0x2E)
DEL key

(0x2F)
HELP key

(0x3A-40)
Undefined

(0x5B)
Left Windows key (Microsoft Natural keyboard)

(0x5C)
Right Windows key (Natural keyboard)

(0x5D)
Applications key (Natural keyboard)

(0x5E)
Reserved

(0x5F)
Computer Sleep key

(0x60)
Numeric keypad 0 key

(0x61)
Numeric keypad 1 key

(0x62)
Numeric keypad 2 key

(0x63)
Numeric keypad 3 key

(0x64)
Numeric keypad 4 key

(0x65)
Numeric keypad 5 key

(0x66)
Numeric keypad 6 key

(0x67)
Numeric keypad 7 key

(0x68)
Numeric keypad 8 key

(0x69)
Numeric keypad 9 key

(0x6A)
Multiply key

(0x6B)
Add key

(0x6C)
Separator key

(0x6D)
Subtract key

(0x6E)
Decimal key

(0x6F)
Divide key

(0x70)
F1 key

(0x71)
F2 key

(0x72)
F3 key

(0x73)
F4 key

(0x74)
F5 key

(0x75)
F6 key

(0x76)
F7 key

(0x77)
F8 key

(0x78)
F9 key

(0x79)
F10 key

(0x7A)
F11 key

(0x7B)
F12 key

(0x7C)
F13 key

(0x7D)
F14 key

(0x7E)
F15 key

(0x7F)
F16 key

(0x80H)
F17 key

(0x81H)
F18 key

(0x82H)
F19 key

(0x83H)
F20 key

(0x84H)
F21 key

(0x85H)
F22 key

(0x86H)
F23 key

(0x87H)
F24 key

(0x88-8F)
Unassigned

(0x90)
NUM LOCK key

(0x91)
SCROLL LOCK key

(0x97-9F)
Unassigned

(0xA0)
Left SHIFT key

(0xA1)
Right SHIFT key

(0xA2)
Left CONTROL key

(0xA3)
Right CONTROL key

(0xA4)
Left MENU key

(0xA5)
Right MENU key

(0xA6)
Windows 2000/XP: Browser Back key

(0xA7)
Windows 2000/XP: Browser Forward key

(0xA8)
Windows 2000/XP: Browser Refresh key

(0xA9)
Windows 2000/XP: Browser Stop key

(0xAA)
Windows 2000/XP: Browser Search key

(0xAB)
Windows 2000/XP: Browser Favorites key

(0xAC)
Windows 2000/XP: Browser Start and Home key

(0xAD)
Windows 2000/XP: Volume Mute key

(0xAE)
Windows 2000/XP: Volume Down key

(0xAF)
Windows 2000/XP: Volume Up key

(0xB0)
Windows 2000/XP: Next Track key

(0xB1)
Windows 2000/XP: Previous Track key

(0xB2)
Windows 2000/XP: Stop Media key

(0xB3)
Windows 2000/XP: Play/Pause Media key

(0xB4)
Windows 2000/XP: Start Mail key

(0xB5)
Windows 2000/XP: Select Media key

(0xB6)
Windows 2000/XP: Start Application 1 key

(0xB7)
Windows 2000/XP: Start Application 2 key

(0xB8-B9)
Reserved

(0xBA)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the ';:' key

(0xBB)
Windows 2000/XP: For any country/region, the '+' key

(0xBC)
Windows 2000/XP: For any country/region, the ',' key

(0xBD)
Windows 2000/XP: For any country/region, the '-' key

(0xBE)
Windows 2000/XP: For any country/region, the '.' key

(0xBF)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the '/?' key

(0xC0)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the '`~' key

(0xC1-D7)
Reserved

(0xD8-DA)
Unassigned

(0xDB)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the '[{' key

(0xDC)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the '\|' key

(0xDD)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the ']}' key

(0xDE)
Used for miscellaneous characters; it can vary by keyboard.

Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key

(0xDF)
Used for miscellaneous characters; it can vary by keyboard.

(0xE0)
Reserved

(0xE2)
Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard

(0xE5)
Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key

(0xE7)
Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP

(0xE8)
Unassigned

(0xF6)
Attn key

(0xF7)
CrSel key

(0xF8)
ExSel key

(0xF9)
Erase EOF key

(0xFA)
Play key

(0xFB)
Zoom key

(0xFC)
Reserved

(0xFD)
PA1 key

(0xFE)
Clear key

至于具体十六进制数代表什么功能,我在MSDN找到了答案。
(http://msdn.microsoft.com/en-us/library/ms645540(VS.85).aspx)

下面摘录一段:

VK_BROWSER_BACK (0xA6)
Windows 2000/XP: Browser Back key

VK_BROWSER_FORWARD (0xA7)
Windows 2000/XP: Browser Forward key

VK_BROWSER_REFRESH (0xA8)
Windows 2000/XP: Browser Refresh key

VK_BROWSER_STOP (0xA9)
Windows 2000/XP: Browser Stop key

VK_BROWSER_SEARCH (0xAA)
Windows 2000/XP: Browser Search key

VK_BROWSER_FAVORITES (0xAB)
Windows 2000/XP: Browser Favorites key

VK_BROWSER_HOME (0xAC)
Windows 2000/XP: Browser Start and Home key

VK_VOLUME_MUTE (0xAD)
Windows 2000/XP: Volume Mute key

VK_VOLUME_DOWN (0xAE)
Windows 2000/XP: Volume Down key

VK_VOLUME_UP (0xAF)
Windows 2000/XP: Volume Up key

VK_MEDIA_NEXT_TRACK (0xB0)
Windows 2000/XP: Next Track key

VK_MEDIA_PREV_TRACK (0xB1)
Windows 2000/XP: Previous Track key

VK_MEDIA_STOP (0xB2)
Windows 2000/XP: Stop Media key

VK_MEDIA_PLAY_PAUSE (0xB3)
Windows 2000/XP: Play/Pause Media key

VK_LAUNCH_MAIL (0xB4)
Windows 2000/XP: Start Mail key

VK_LAUNCH_MEDIA_SELECT (0xB5)
Windows 2000/XP: Select Media key

VK_LAUNCH_APP1 (0xB6)
Windows 2000/XP: Start Application 1 key

VK_LAUNCH_APP2 (0xB7)
Windows 2000/XP: Start Application 2 key

B6 Application 1 就是我的电脑
B7 Application 2 就是计算器

为了更方便的实现这些功能,我编了一段简单的vbs

复制代码 代码如下:

a=chr(&h88b5)
'msgbox "d" & a & "d"
CreateObject("wscript.shell").Sendkeys a

简单的解释一下
a=chr(&h88b5)
'“&h”表示后面的数是十六进制数,b5代表Media key,也就是媒体播放器(比如千千静听),为什么前面要加88呢?加了88以后,有两个字节,也就构成了一个汉字(是GBK里的),因为a代表的字符若不是真正有意义的字符(比如ASCII字符和汉字),sendkeys就不会起作用,大家可以试一下。至于为什么选择88,因为在msdn里写着(0x88-8F)Unassigned,同时88为开头的字符可以组成有意义的GBK汉字。
复制代码 代码如下:

'msgbox "d" & a & "d"
'可以测试a是不是有意义的字符
CreateObject("wscript.shell").Sendkeys a
'调用SendKeys方法。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3