欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-07-04 20:39:34
constants vk_lbutton  (0x01) left mouse button vk_rbutton  (0x0...

constants

vk_lbutton  (0x01)
left mouse button

vk_rbutton  (0x02)
right mouse button

vk_cancel  (0x03)
control-break processing

vk_mbutton  (0x04)
middle mouse button (three-button mouse)

vk_xbutton1  (0x05)
windows 2000/xp: x1 mouse button

vk_xbutton2  (0x06)
windows 2000/xp: x2 mouse button

-  (0x07)
undefined

vk_back  (0x08)
backspace key

vk_tab  (0x09)
tab key

-  (0x0a-0b)
reserved

vk_clear  (0x0c)
clear key

vk_return  (0x0d)
enter key

-  (0x0e-0f)
undefined

vk_shift  (0x10)
shift key

vk_control  (0x11)
ctrl key

vk_menu  (0x12)
alt key

vk_pause  (0x13)
pause key

vk_capital  (0x14)
caps lock key

vk_kana  (0x15)
input method editor (ime) kana mode

vk_hanguel  (0x15)
ime hanguel mode (maintained for compatibility; use vk_hangul)

vk_hangul  (0x15)
ime hangul mode

-  (0x16)
undefined

vk_junja  (0x17)
ime junja mode

vk_final  (0x18)
ime final mode

vk_hanja  (0x19)
ime hanja mode

vk_kanji  (0x19)
ime kanji mode

-  (0x1a)
undefined

vk_escape  (0x1b)
esc key

vk_convert  (0x1c)
ime convert

vk_nonconvert  (0x1d)
ime nonconvert

vk_accept  (0x1e)
ime accept

vk_modechange  (0x1f)
ime mode change request

vk_space  (0x20)
spacebar

vk_prior  (0x21)
page up key

vk_next  (0x22)
page down key

vk_end  (0x23)
end key

vk_home  (0x24)
home key

vk_left  (0x25)
left arrow key

vk_up  (0x26)
up arrow key

vk_right  (0x27)
right arrow key

vk_down  (0x28)
down arrow key

vk_select  (0x29)
select key

vk_print  (0x2a)
print key

vk_execute  (0x2b)
execute key

vk_snapshot  (0x2c)
print screen key

vk_insert  (0x2d)
ins key

vk_delete  (0x2e)
del key

vk_help  (0x2f)
help key

 (0x30)
0 key

 (0x31)
1 key

 (0x32)
2 key

 (0x33)
3 key

 (0x34)
4 key

 (0x35)
5 key

 (0x36)
6 key

 (0x37)
7 key

 (0x38)
8 key

 (0x39)
9 key

-  (0x3a-40)
undefined

 (0x41)
a key

 (0x42)
b key

 (0x43)
c key

 (0x44)
d key

 (0x45)
e key

 (0x46)
f key

 (0x47)
g key

 (0x48)
h key

 (0x49)
i key

 (0x4a)
j key

 (0x4b)
k key

 (0x4c)
l key

 (0x4d)
m key

 (0x4e)
n key

 (0x4f)
o key

 (0x50)
p key

 (0x51)
q key

 (0x52)
r key

 (0x53)
s key

 (0x54)
t key

 (0x55)
u key

 (0x56)
v key

 (0x57)
w key

 (0x58)
x key

 (0x59)
y key

 (0x5a)
z key

vk_lwin  (0x5b)
left windows key (microsoft natural keyboard)

vk_rwin  (0x5c)
right windows key (natural keyboard)

vk_apps  (0x5d)
applications key (natural keyboard)

-  (0x5e)
reserved

vk_sleep  (0x5f)
computer sleep key

vk_numpad0  (0x60)
numeric keypad 0 key

vk_numpad1  (0x61)
numeric keypad 1 key

vk_numpad2  (0x62)
numeric keypad 2 key

vk_numpad3  (0x63)
numeric keypad 3 key

vk_numpad4  (0x64)
numeric keypad 4 key

vk_numpad5  (0x65)
numeric keypad 5 key

vk_numpad6  (0x66)
numeric keypad 6 key

vk_numpad7  (0x67)
numeric keypad 7 key

vk_numpad8  (0x68)
numeric keypad 8 key

vk_numpad9  (0x69)
numeric keypad 9 key

vk_multiply  (0x6a)
multiply key

vk_add  (0x6b)
add key

vk_separator  (0x6c)
separator key

vk_subtract  (0x6d)
subtract key

vk_decimal  (0x6e)
decimal key

vk_divide  (0x6f)
divide key

vk_f1  (0x70)
f1 key

vk_f2  (0x71)
f2 key

vk_f3  (0x72)
f3 key

vk_f4  (0x73)
f4 key

vk_f5  (0x74)
f5 key

vk_f6  (0x75)
f6 key

vk_f7  (0x76)
f7 key

vk_f8  (0x77)
f8 key

vk_f9  (0x78)
f9 key

vk_f10  (0x79)
f10 key

vk_f11  (0x7a)
f11 key

vk_f12  (0x7b)
f12 key

vk_f13  (0x7c)
f13 key

vk_f14  (0x7d)
f14 key

vk_f15  (0x7e)
f15 key

vk_f16  (0x7f)
f16 key

vk_f17  (0x80h)
f17 key

vk_f18  (0x81h)
f18 key

vk_f19  (0x82h)
f19 key

vk_f20  (0x83h)
f20 key

vk_f21  (0x84h)
f21 key

vk_f22  (0x85h)
f22 key

vk_f23  (0x86h)
f23 key

vk_f24  (0x87h)
f24 key

-  (0x88-8f)
unassigned

vk_numlock  (0x90)
num lock key

vk_scroll  (0x91)
scroll lock key

 (0x92-96)
oem specific

-  (0x97-9f)
unassigned

vk_lshift  (0xa0)
left shift key

vk_rshift  (0xa1)
right shift key

vk_lcontrol  (0xa2)
left control key

vk_rcontrol  (0xa3)
right control key

vk_lmenu  (0xa4)
left menu key

vk_rmenu  (0xa5)
right menu key

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

-  (0xb8-b9)
reserved

vk_oem_1  (0xba)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the ';:' key

vk_oem_plus  (0xbb)
windows 2000/xp: for any country/region, the '+' key

vk_oem_comma  (0xbc)
windows 2000/xp: for any country/region, the ',' key

vk_oem_minus  (0xbd)
windows 2000/xp: for any country/region, the '-' key

vk_oem_period  (0xbe)
windows 2000/xp: for any country/region, the '.' key

vk_oem_2  (0xbf)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the '/?' key

vk_oem_3  (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

vk_oem_4  (0xdb)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the '[{' key

vk_oem_5  (0xdc)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the '\|' key

vk_oem_6  (0xdd)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the ']}' key

vk_oem_7  (0xde)
used for miscellaneous characters; it can vary by keyboard.

windows 2000/xp: for the us standard keyboard, the 'single-quote/double-quote' key

vk_oem_8  (0xdf)
used for miscellaneous characters; it can vary by keyboard.

-  (0xe0)
reserved

 (0xe1)
oem specific

vk_oem_102  (0xe2)
windows 2000/xp: either the angle bracket key or the backslash key on the rt 102-key keyboard

 (0xe3-e4)
oem specific

vk_processkey  (0xe5)
windows 95/98/me, windows nt 4.0, windows 2000/xp: ime process key

 (0xe6)
oem specific

vk_packet  (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

 (0xe9-f5)
oem specific

vk_attn  (0xf6)
attn key

vk_crsel  (0xf7)
crsel key

vk_exsel  (0xf8)
exsel key

vk_ereof  (0xf9)
erase eof key

vk_play  (0xfa)
play key

vk_zoom  (0xfb)
zoom key

vk_noname  (0xfc)
reserved

vk_pa1  (0xfd)
pa1 key

vk_oem_clear  (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方法。