键盘虚拟键值编码表 使用keybd

合集下载

虚拟按键

虚拟按键
让 WIN95 模拟按了一个按键 ,例如按下 ENTER 或者 TAB 键 ?
PostMessage(Object.Handle, WM_KEYDOWN, VK_TAB, 0);
////////////////////////////////
unit Unit1;
interface
Re:
Use the keybd_event API function to fake keyboard events. Note that each
key down event needs a matching key up or you mess up the key state array.
SendMessage(H, WM_CHAR, vKey, lParam);
lParam:= lParam or $C0000000;
SendMessage(H, WM_KEYUP, vKey, lParam);
if Shift then SendShift(H, false);
经本人试验 ,确实可行 ,另加补充 :
Ctrl: VK_CONTROL
SHIFT:VK_SHIFT
TAB: VK_TAB
'A': byte('A') (98-6-8 22:28)
/////////////////////////////////////////////////////////////
wParam:= vKey or ScanCode shl 8;
lParam:= longint(ScanCode) shl 16 or 1;
if not(Down) then lParam:= lParam or $C0000000;

虚拟键盘对应值

虚拟键盘对应值

VK_PRIOR 21 33 Page Up键VK_NEXT 22 34 Page Down键VK_END 23 35 End键VK_HOME 24 36 Home键VK_LEFT 25 37 Left Arrow键VK_UP 26 38 Up Arrow键VK_RIGHT 27 39 Right Arrow键VK_DOWN 28 40 Down Arrow键VK_SELECT 29 41 Select键2A 42 OEM自订使用VK_EXECUTE 2B 43 Execute键VK_SNAPSHOT 2C 44 Print Screen键VK_INSERT 2D 45 Ins键VK_DELETE 2E 46 Del键VK_HELP 2F 47 Help键VK_0 30 48 0键VK_1 31 49 1键VK_2 32 50 2键VK_3 33 51 3键VK_4 34 52 4键VK_5 35 53 5键VK_6 36 54 6键VK_7 37 55 7键VK_8 38 56 8键VK_9 39 57 9键3A-40 58-64 未定义VK_A 41 65 A键VK_B 42 66 B键VK_C 43 67 C键VK_D 44 68 D键VK_E 45 69 E键VK_F 46 70 F键VK_G 47 71 G键VK_H 48 72 H键VK_I 49 73 I键VK_J 4A 74 J键VK_K 4B 75 K键VK_L 4C 76 L键VK_M 4D 77 M键VK_N 4E 78 N键VK_O 4F 79 O键VK_P 50 80 P键VK_Q 51 81 Q键VK_R 52 82 R键VK_S 53 83 S键VK_T 54 84 T键VK_U 55 85 U键VK_V 56 86 V键VK_W 57 87 W键VK_X 58 88 X键VK_Y 59 89 Y键VK_Z 5A 90 Z键5B-5F 91-95 未定义VK_NUMPAD0 60 96 数字键0键VK_NUMPAD1 61 97 数字键1键VK_NUMPAD2 62 98 数字键2键VK_NUMPAD3 63 99 数字键3键VK_NUMPAD4 64 100 数字键4键VK_NUMPAD5 65 101 数字键5键VK_NUMPAD6 66 102 数字键6键VK_NUMPAD7 67 103 数字键7键VK_NUMPAD8 68 104 数字键8键VK_NUMPAD9 69 105 数字键9键VK_MULTIPLY 6A 106 *键VK_ADD 6B 107 +键VK_SEPARATOR 6C 108 Separator键VK_SUBTRACT 6D 109 -键VK_DECIMAL 6E 110 .键VK_DIVIDE 6F 111 /键VK_F1 70 112 F1键VK_F2 71 113 F2键VK_F3 72 114 F3键VK_F4 73 115 F4键VK_F5 74 116 F5键VK_F6 75 117 F6键VK_F7 76 118 F7键VK_F8 77 119 F8键VK_F9 78 120 F9键VK_F10 79 121 F10键VK_F11 7A 122 F11键VK_F12 7B 123 F12键VK_F13 7C 124 F13键VK_F14 7D 125 F14键VK_F15 7E 126 F15键VK_F16 7F 127 F16键VK_F17 80 128 F17键VK_F18 81 129 F18键VK_F19 82 130 F19键VK_F20 83 131 F20键VK_F21 84 132 F21键VK_F22 85 133 F22键VK_F23 86 134 F23键VK_F24 87 135 F24键88-8F 136-143 未指定VK_NUMLOCK 90 144 Num Lock键VK_SCROLL 91 145 Scroll Lock键92-B9 146-185 未指定BA-C0 186-192 OEM自订C1-DA 193-218 未指定DB-E4 219-228 OEM自订E5 229 未指定E6 230 OEM自订E7-E8 231-232 未指定E9-F5 233-245 OEM自订F6-FE 246-254 未指定2005-6-28 13:55:27发表评语»»»2005-7-12 10:55:42 模拟键盘鼠标的操作KeyLife富翁笔记作者 : chen_liang标题 : 模拟键盘鼠标关键字:分类 : 个人专区密级 : 公开(评分: , 回复: 0, 阅读: 50) »»在Windows大行其道的今天,windows界面程序受到广大用户的欢迎。

键盘键与虚拟键码对照表

键盘键与虚拟键码对照表

键盘键与虚拟键码对照表字母和数字键数字小键盘的键功能键其它键键键码键键码键键码键键码A 65 096F1112Backspace8B 66 1 97F2113 Tab9C 67298F3114 Clear12D 68 3 99F4115 Enter13E 69 4100 F5116 Shift 16F 70 5101 F6117 Control 17G 71 6 102 F7118Alt18H 72 7103 F8119 Caps Lock20I 738104 F9120 Esc27J 749 105 F10 121 Spacebar 32K 75 *106 F11 122 Page Up 33L 76 +107 F12 123 Page Down34M 77Enter 108 ---- End35 N 78- 109 ---- Home 36O 79 .110 -- --Left Arrow 37 P 80/111 -- --Up Arrow 38Q 81---- -- --Right Arrow39 R 82---- -- --Down Arrow40 S 83---- ---- Insert45 T 84---- -- --Delete46 U 85---- ----Help47 V 86-- -- ----Num Lock144 W 87X 88Y 89Z 900 481 492 503 514 525 536 547 558 569 570x1鼠标左键0x2鼠标右键0x3CANCEL键0x4鼠标中键0x8BACKSPACE键0x9TAB键0xC CLEAR键0xD ENTER键0x10SHIFT键0x11CTRL键0x12MENU键0x13PAUSE键0x14CAPS LOCK键0x1B ESC键0x20SPACEBAR键0x21PAGE UP键0x22PAGE DOWN键0x23END键0x24HOME键0x25LEFT ARROW键0x26UP ARROW键0x27RIGHT ARROW键0x28DOWN ARROW键0x29Select键0x2A PRINT SCREEN键0x2B EXECUTE键0x2C SNAPSHOT键0x2D Insert键0x2E Delete键0x2F HELP键0x90NUM LOCK键A至Z键与A–Z字母的ASCII码相同:值描述65A键66B键67C键68D键69E键70F键71G键72H键73I键74J键75K键76L键77M键78N键79O键80P键81Q键82R键83S键84T键85U键86V键87W键88X键89Y键90Z键0至9键与数字0–9的ASCII码相同:480键491键502键513键524键535键546键557键568键579键下列常数代表数字键盘上的键:值描述0x600键0x611键0x622键0x633键0x644键0x655键0x666键0x677键0x688键0x699键0x6A MULTIPLICATION SIGN(*)键0x6B PLUS SIGN(+)键0x6C ENTER键0x6D MINUS SIGN(–)键0x6E DECIMAL POINT(.)键0x6F DIVISION SIGN(/)键下列常数代表功能键:0x70F1键0x71F2键0x72F3键0x73F4键0x74F5键0x75F6键0x76F7键0x77F8键0x78F9键0x79F10键0x7A F11键0x7B F12键0x7C F13键0x7D F14键0x7E F15键0x7F F16键0None3Cancel(Break)8Back9Tab13Return16ShiftKey17ControlKey18Menu19Pause20Capital(大小写)27Escape32Space33PageUp34Next(PageDonw) 35End36Home37Left38Up39Right40Down0-948-5745Insert46Delete65->90A->Z91LWin93Apps96105NumPad0- 106Multiply* 107Add+108109Subtract-110Decimal.111Divide/112-123F1-F12144NumLock145Scroll173VolumeMute174VolumeDown175VolumeUp186Oem1;187Oemplus=188Oemcomma,189OemMinus-190OemPeriod.191OemQuestion/192Oemtilde`219OemOpenBrackets[ 220Oem5\221Oem6]222Oem7'欢迎您的下载,资料仅供参考!致力为企业和个人提供合同协议,策划案计划书,学习资料等等打造全网一站式需求。

PB 代码模拟按键 API函数keybd_event 及相应的键值说明

PB 代码模拟按键 API函数keybd_event 及相应的键值说明
vbKeyMenu 18 菜单键
vbKeyPause 19 PAUSE 键
vbKeyCapital 20 CAPS LOCK 键
vbKeyEscape 27 ESC 键
vbKeySpace 32 SPACEBAR 键
vbKeyPageUp 33 PAGEUP 键
vbKeyPageDown 34 PAGEDOWN 键
vbKeyMButton 4 鼠标中键
vbKeyBack 8 BACKSPACE 键
vbKeyTab 9 TAB 键
vbKeyClear 12 CLEAR 键
vbKeyReturn 13 ENTER 键
vbKeyShift 16 SHIFT 键
vbKeyControl 17 CTRL 键
vbKeyF7 118 F7 键
vbKeyF8 119 F8 键
vbKeyF9 120 F9 键
vbKeyF10 121 F10 键
vbKeyF11 122 F11 键
vbKeyF12 123 F12 键
vbKeyF13 124 F13 键
vbKeyF14 125 F14 键
vbKey4 52 4 键
vbKey5 53 5 键
vbKey6 54 6 键
vbKey7 55 7 键
vbKey8 56 8 键
vbKey9 57 9 键
数字小键盘上的键
常数 值 描述
vbKeyNumpad0 96 0 键
vbKeyNumpad1 97 1 键
vbKeyN 78 N 键
vbKeyO 79 O 键
vbKeyP 80 P 键

键盘按键的各种编码对照表(全)

键盘按键的各种编码对照表(全)

键盘按键的各种编码对照表(全)键盘按键的各种编码对照表本附录中的各表列举了键盘按键扫描码和其ASCII码之间的对照关系,表中数据都是十六进制形式。

在用中断16H的0号功能时,当按下任意一个键或组合键时,寄存器AH和AL分别保存着该按键的扫描码和ASCII码。

表1、ASCII码的编码方案高位000001010011100101110111低位0000NUL DEL SP0@P`p0001SOH DC1!1A Q a q0010STX DC2“2B R b r0011ETX DC3#3C S c s0100EOT DC4$4D T d t0101ENQ NAK%5E U e u0110ACK SYN&6F V f v0111BEL ETB‘7G W g w1000BS CAN(8H X h x1001HT EM)9I Y i y1010LF SUB*:J Z j z1011VT ESC+;K[k{1100FF FS<l\l|< p="">1101CR GS-=M]m}1110SO RS.>N^n~1111SI US/?O_o Del表2、字母和空格按键的编码表单键SHIFT CTRL ALT 按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码a and A1E611E411E011E00b and B3062304230023000c and C2E632E432E032E00d and D2064204420042000e and E1265124512051200f and F2166214621062100g and G2267224722072200h and H2368234823082300i and I1769174917091700j an1 J246A244A240A2400 k and K256B254B250B2500 l and L266C264C260C2600m and M326D324D320D3200 n and N316E314E310E3100 o and O186F184F180F1800 p and P1970195019101900 q and Q1071105110111000 r and R1372135213121300 s and S1F731F531F131F00 t and T1474145414141400 u and U1675165516151600 v and V2F762F562F162F00w and W1177115711171100 x and X2D782D582D182D00 y and Y1579155915191500 z and Z2C7A2C5A2C1A2C00 SpaceBar3920392039203920表3、功能键的编码表单键SHIFT CTRL ALT按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码F13B0054005E006800 F23C0055005F006900 F33D00560060006A00 F43E00570061006B00 F53F00580062006C00 F64000590063006D00 F741005A0064006E00 F842005B0065006F00 F943005C0066007000 F1044005D0067007100 F118500870089008B00 F12860088008A008C00 表4、数字键盘的编码表单键SHIFT CTRL ALT 按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码Ins & 0 52 00 52 30 92 00End & 14F004F3175000001↓& 25000503291000002 PgDn & 35100513376000003←& 44B004B3473000004 54C004C358F000005→& 64D004D3674000006 Home & 74700473777000007↑& 8480048388D000008 PgUp & 94900493984000009 +4E2B4E2B90004E00-4A2D4A2D8E004A00 Del & '.'53 00 53 2E 93 00*372A372A96003700表5、第一排数字键盘的编码表单键SHIFT CTRL ALT 按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码` and ~2960297E29001 and !023*********2 and @03320340030079003 and #043304237A004 and $053405247B005 and %063506257C006 and ^0736075E071E7D007 and &083708267E008 and *0938092A7F009 and (0A390A3880000 and )0B300B298100- and _0C2D0C5F0C1F8200= and +0D3D0D2B8300表6、操作按键的编码表单键SHIFT CTRL ALT 按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码Esc011B011B011B0100 Backspace0E080E080E7F0E00 Tab0F090F009400A500 Enter1C0D1C0D1C0A1C00表7、标号按键的编码表单键SHIFT CTRL ALT按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码[ and {1A5B1A7B1A1B1A00] and }1B5D1B7D1B1D1B00; and :273B273A27' and "2827282228\ and |2b5C2b7C2B1C2b, and <332C333C33. and >342E343E34/ and ?352F353F35表8、附加按键的编码表单键SHIFT CTRL ALT 按键扫描码ASCII码扫描码ASCII码扫描码ASCII码扫描码ASCII码Slash(/)E02F E02F9500A400 Enter E00D E00D E00A A600 Home47E047E077E09700 End4F E04F E075E09F00 PageUp49E049E084E09900 PageDown51E051E076E0A100 DnArrow50E050E091E0A000 LeftArrow4B E04B E073E09B00 RightArrow4D E04D E074E09D00 UpArrow48E048E08D E09800 Ins52E052E092E0A200 Del53E053E093E0A300表9、其它按键的扫描码当这些键被按下时,BIOS并没有把它们的扫描码输入键盘缓冲区。

键盘对应数字-keycode值大全

键盘对应数字-keycode值大全

键盘对应数字-keycode值大全键盘对应数字-keycode值大event.keycode值大全 1 keycode 8 = BackSpace BackSpace 2 keycode 9 = Tab T ab 3 keycode 12 = Clear 4 keycode 13 = Enter 5 keycode 16 = Shift_L 6 keycode 17 = Control_L 7 keycode 18 = Alt_L 8 keycode 19 = Pause 9 keycode 20 = Caps_Lock 10 key event.keycode值大全1 keycode 8 = BackSpace BackSpace2 keycode 9 = Tab Tab3 keycode 12 = Clear4 keycode 13 = Enter5 keycode 16 = Shift_L6 keycode 17 = Control_L7 keycode 18 = Alt_L8 keycode 19 = Pause9 keycode 20 = Caps_Lock10 keycode 27 = Escape Escape11 keycode 32 = space space12 keycode 33 = Prior13 keycode 34 = Next14 keycode 35 = End15 keycode 36 = Home17 keycode 38 = Up18 keycode 39 = Right19 keycode 40 = Down20 keycode 41 = Select21 keycode 42 = Print23 keycode 45 = Insert24 keycode 46 = Delete25 keycode 47 = Help26 keycode 48 = 0 equal braceright27 keycode 49 = 1 exclam onesuperior28 keycode 50 = 2 quotedbl twosuperior29 keycode 51 = 3 section threesuperior30 keycode 52 = 4 dollar31 keycode 53 = 5 percent32 keycode 54 = 6 ampersand33 keycode 55 = 7 slash braceleft34 keycode 56 = 8 parenleft bracketleft35 keycode 57 = 9 parenright bracketright37 keycode 66 = b B38 keycode 67 = c C39 keycode 68 = d D40 keycode 69 = e E EuroSign41 keycode 70 = f F4243 keycode 71 = g G44 keycode 72 = h H45 keycode 73 = i I46 keycode 74 = j J47 keycode 75 = k K48 keycode 76 = l L49 keycode 77 = m M mu50 keycode 78 = n N51 keycode 79 = o O52 keycode 80 = p P54 keycode 82 = r R55 keycode 83 = s S56 keycode 84 = t T57 keycode 85 = u U59 keycode 87 = w W60 keycode 88 = x X61 keycode 89 = y Y62 keycode 90 = z Z63 keycode 96 = KP_0 KP_064 keycode 97 = KP_1 KP_165 keycode 98 = KP_2 KP_266 keycode 99 = KP_3 KP_367 keycode 100 = KP_4 KP_468 keycode 101 = KP_5 KP_569 keycode 102 = KP_6 KP_670 keycode 103 = KP_7 KP_771 keycode 104 = KP_8 KP_872 keycode 105 = KP_9 KP_973 keycode 106 = KP_Multiply KP_Multiply74 keycode 107 = KP_Add KP_Add7576 keycode 108 = KP_Separator KP_Separator77 keycode 109 = KP_Subtract KP_Subtract78 keycode 110 = KP_Decimal KP_Decimal79 keycode 111 = KP_Divide KP_Divide80 keycode 112 = F181 keycode 113 = F282 keycode 114 = F383 keycode 115 = F4848586 keycode 116 = F587 keycode 117 = F688 keycode 118 = F789 keycode 119 = F890 keycode 120 = F991 keycode 121 = F1092 keycode 122 = F1193 keycode 123 = F1294 keycode 124 = F1395 keycode 125 = F1496 keycode 126 = F1597 keycode 127 = F1698 keycode 128 = F1799 keycode 129 = F18100 keycode 130 = F19101 keycode 131 = F20102 keycode 132 = F21103 keycode 133 = F22104 keycode 134 = F23105 keycode 135 = F24106 keycode 136 = Num_Lock107 keycode 137 = Scroll_Lock108 keycode 187 = acute grave109 keycode 188 = comma semicolon110 keycode 189 = minus underscore111 keycode 190 = period colon112 keycode 192 = numbersign apostrophe 113 keycode 210 = plusminus hyphen macron114 keycode 211 =115 keycode 212 = copyright registered116 keycode 213 = guillemotleft guillemotright 117 keycode 214 = masculine ordfeminine118 keycode 215 = ae AE119 keycode 216 = cent yen120 keycode 217 = questiondown exclamdown121 keycode 218 = onequarter onehalf threequarters122 keycode 220 = less greater bar123 keycode 221 = plus asterisk asciitilde124 keycode 227 = multiply division125126 keycode 228 = acircumflex Acircumflex127 keycode 229 = ecircumflex Ecircumflex128 keycode 230 = icircumflex Icircumflex129 keycode 231 = ocircumflex Ocircumflex130 keycode 232 = ucircumflex Ucircumflex131 keycode 233 = ntilde Ntilde132 keycode 234 = yacute Yacute133 keycode 235 = oslash Ooblique134 keycode 236 = aring Aring135 keycode 237 = ccedilla Ccedilla136 keycode 238 = thorn THORN137 keycode 239 = eth ETH138 keycode 240 = diaeresis cedilla currency139 keycode 241 = agrave Agrave atilde Atilde140 keycode 242 = egrave Egrave141 keycode 243 = igrave Igrave142 keycode 244 = ograve Ograve otilde Otilde143 keycode 245 = ugrave Ugrave144 keycode 246 = adiaeresis Adiaeresis145 keycode 247 = ediaeresis Ediaeresis146 keycode 248 = idiaeresis Idiaeresis147 keycode 249 = odiaeresis Odiaeresis148 keycode 250 = udiaeresis Udiaeresis149 keycode 251 = ssharp question backslash150 keycode 252 = asciicircum degree151 keycode 253 = 3 sterling152 keycode 254 = Mode_switch153154 使用event对象的keyCode属性判断输入的键值155 eg:if(event.keyCode==13)alert(“enter!”);156 键值对应表157 A0X65 U 0X85 158 B0X66V0X86 159 C0X67W0X87 160 D0X68X 0X88 161 E0X69Y0X89 162 F0X70Z0X90 163 G0X7100X48 164 H0X7210X49 165 I 0X7320X50 166 J 0X74 3 0X51 167 K0X75 4 0X52 168 L0X76 5 0X53 169 M0X7760X54 170 N0X78 7 0X55 171 O0X79 8 0X56 172 P0X80 9 0X57 173 Q0X81ESC0X1B 174 R0X82CTRL 0X11 175 S0X83SHIFT0X10 176 T0X84ENTER0XD 177178如果要使用组合键,则可以利用event.ctrlKey,event.shiftKey,event .altKey判断是否按下了ctrl键、shift 键以及alt键转自:经典文章网(/doc/955800866.html,) - 详文链接:/doc/955800866.html,/zonghe/biancheng/65.h tml用VB编写键盘任意组合键(包括2、3、4键组合)在一些程序中,有一些快捷方式(如:Shift键最小化、ESC键退出、Ctrl+S存盘、Alt+x退出等等)。

虚拟键盘值表

虚拟键盘值表
B 66 1 97 F2 113 Tab 9
C 67 2 98 F3 114 Clear 12
D 68 3 99 F4 115 Enter 13
0x7D F14 键
0x7E F15 键
0x7F F16 键
50 2 键
51 3 键
52 4 键
53 5 键
54 6 键
55 7 键
56 8 键
57 9 键
下列常数代表数字键盘上的键:
值 描述
0x60 0 键
0x61 1 键
0x62 2 键
0x63 3 键
0x64 4 键
0x65 5 键
0x66 6 键
0x67 7 键
0x2E DELETE 键
0x2F HELP 键
0x90 NUM LOCK 键
A 至 Z 键与 A - Z 字母的 ASCII 码相同:
值 描述
65 A 键
66 B 键
67 C 键
68 D 键
69 E 键
70 F 键
71 G 键
72 H 键
73 I 键
74 J 键
75 K 键
字母和数字键 数字小键盘的键 功能键 其它键
键 键码 键 键码 键 键码 键 键码
A 65 0 96 F1 112 Backspace 8
例子1:模拟按下'A'键
keybd_event(65,0,0,0);
keybd_event(65,0,KEYEVENTF_KEYUP,0);
例子2:模拟按下'ALT+F4'键
keybd_event(18,0,0,0);

虚拟键码表

虚拟键码表

下面就是虚拟键码表Virtual Key Code Corresponding key VK_LBUTTON Left mouse buttonVK_RBUTTON Right mouse buttonVK_CANCEL Control+BreakVK_MBUTTON Middle mouse buttonVK_BACK Backspace keyVK_TAB Tab keyVK_CLEAR Clear keyVK_RETURN Enter keyVK_SHIFT Shift keyVK_CONTROL Ctrl keyVK_MENU Alt keyVK_PAUSE Pause keyVK_CAPITAL Caps Lock keyVK_KANA Used with IMEVK_HANGUL Used with IMEVK_JUNJA Used with IMEVK_FINAL Used with IMEVK_HANJA Used with IMEVK_KANJI Used with IMEVK_CONVERT Used with IMEVK_NONCONVERT Used with IMEVK_ACCEPT Used with IMEVK_MODECHANGE Used with IMEVK_ESCAPE Esc keyVK_SPACE Space barVK_PRIOR Page Up keyVK_NEXT Page Down keyVK_END End keyVK_HOME Home keyVK_LEFT Left Arrow keyVK_UP Up Arrow keyVK_RIGHT Right Arrow keyVK_DOWN Down Arrow keyVK_SELECT Select keyVK_PRINT Print key (keyboard-specific)VK_EXECUTE Execute keyVK_SNAPSHOT Print Screen keyVK_INSERT Insert keyVK_DELETE Delete keyVK_HELP Help keyVK_LWIN Left Windows key (Microsoft keyboard)VK_RWIN Right Windows key (Microsoft keyboard) VK_APPS Applications key (Microsoft keyboard)VK_NUMPAD0 0 key (numeric keypad)VK_NUMPAD1 1 key (numeric keypad)VK_NUMPAD2 2 key (numeric keypad)VK_NUMPAD3 3 key (numeric keypad)VK_NUMPAD4 4 key (numeric keypad)VK_NUMPAD5 5 key (numeric keypad)VK_NUMPAD6 6 key (numeric keypad)VK_NUMPAD7 7 key (numeric keypad)VK_NUMPAD8 8 key (numeric keypad)VK_NUMPAD9 9 key (numeric keypad)VK_MULTIPL Y Multiply key (numeric keypad)VK_ADD Add key (numeric keypad)VK_SEPARATOR Separator key (numeric keypad)VK_SUBTRACT Subtract key (numeric keypad)VK_DECIMAL Decimal key (numeric keypad)VK_DIVIDE Divide key (numeric keypad)VK_F1 F1 keyVK_F2 F2 keyVK_F3 F3 keyVK_F4 F4 key VK_F5 F5 key VK_F6 F6 key VK_F7 F7 key VK_F8 F8 key VK_F9 F9 key VK_F10 F10 key VK_F11 F11 key VK_F12 F12 key VK_F13 F13 key VK_F14 F14 key VK_F15 F15 keyVK_F16 F16 key VK_F17 F17 key VK_F18 F18 key VK_F19 F19 key VK_F20 F20 key VK_F21 F21 key VK_F22 F22 key VK_F23 F23 key VK_F24 F24 keyVK_NUMLOCK Num Lock keyVK_SCROLL Scroll Lock keyVK_LSHIFT Left Shift key (only used with GetAsyncKeyState and G etKeyState)VK_RSHIFT Right Shift key (only used with GetAsyncKeyState and GetKeyState)VK_LCONTROL Left Ctrl key (only used with GetAsyncKeyState an d GetKeyState)VK_RCONTROL Right Ctrl key (only used with GetAsyncKeyState a nd GetKeyState)VK_LMENU Left Alt key (only used with GetAsyncKeyState and GetKeyState)VK_RMENU Right Alt key (only used with GetAsyncKeyState and GetKeyState)VK_PROCESSKEY Process keyVK_ATTN Attn keyVK_CRSEL CrSel keyVK_EXSEL ExSel keyVK_EREOF Erase EOF keyVK_PLAY Play keyVK_ZOOM Zoom keyVK_NONAME Reserved for future useVK_PA1 PA1 keyVK_OEM_CLEAR Clear key。

keybd_event,mouse_event模拟产生键盘事件、鼠标事件的使用

keybd_event,mouse_event模拟产生键盘事件、鼠标事件的使用

keybd_event,mouse_event模拟产生键盘事件、鼠标事件的使用比如一个应用:自动关闭弹出的Messagox对话框(/dijkstar/article/details/8761481)(2013-04-05编辑)void CSimulateMouseView::OnLdbclick(){//将鼠标的位置放在窗口的标题条上POINT lpPoint;CRect rc;CWnd* pParent = AfxGetApp()->GetMainWnd();pParent->GetWindowRect(&rc);lpPoint.x = rc.left+50;lpPoint.y = rc.top+10;SetCursorPos(lpPoint.x, lpPoint.y);//双击该标题条mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);}void CSimulateMouseView::OnLclick(){//将鼠标的位置放在窗口的关闭按钮上POINT lpPoint;CRect rc;CWnd* pParent = AfxGetApp()->GetMainWnd();pParent->GetWindowRect(&rc);lpPoint.x = rc.right-5;lpPoint.y = rc.top +5;SetCursorPos(lpPoint.x, lpPoint.y);//单击mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE,0,0,0,0);mouse_event(MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABS OLUTE,0,0,0,0);}BOOL CSimulateMouseView::PreTranslateMessage(MSG* pMsg){// TODO: Add your specialized code here and/or call the base classif (pMsg->message==WM_KEYDOWN && pMsg->wParam==0x41){::MessageBox(NULL, "A 键按下", "提示", MB_ICONQUESTION);return FALSE; //不翻译消息,直接将消息传递下去。

windows编程 虚拟键值对照表

windows编程 虚拟键值对照表

VK_LBUTTON 鼠标左键0x01VK_RBUTTON 鼠标右键0x02VK_CANCEL Ctrl + Break 0x03VK_MBUTTON 鼠标中键0x04VK_BACK Backspace 键0x08VK_TAB Tab 键0x09VK_RETURN 回车键0x0DVK_SHIFT Shift 键0x10VK_CONTROL Ctrl 键0x11VK_MENU Alt 键0x12VK_PAUSE Pause 键0x13VK_CAPITAL Caps Lock 键0x14VK_ESCAPE Esc 键0x1BVK_SPACE 空格键0x20VK_PRIOR Page Up 键0x21VK_NEXT Page Down 键0x22VK_END End 键0x23VK_HOME Home 键0x24 VK_LEFT 左箭头键0x25VK_UP 上箭头键0x26VK_RIGHT 右箭头键0x27 VK_DOWN 下箭头键0x28 VK_SNAPSHOT Print Screen 键0x2C VK_INSERT Insert 键0x2D VK_DELETE Delete 键0x2E'0' – '9' 数字0 - 9 0x30 - 0x39 'A' – 'Z' 字母A - Z 0x41 - 0x5A VK_LWIN 左WinKey(104键盘才有) 0x5B VK_RWIN 右WinKey(104键盘才有) 0x5C VK_APPS AppsKey(104键盘才有) 0x5DVK_NUMPAD0 小键盘 0 键0x60VK_NUMPAD1 小键盘 1 键0x61VK_NUMPAD2 小键盘 2 键0x62VK_NUMPAD3 小键盘 3 键0x63VK_NUMPAD4 小键盘 4 键0x64VK_NUMPAD5 小键盘 5 键0x65VK_NUMPAD6 小键盘 6 键0x66VK_NUMPAD7 小键盘 7 键0x67VK_NUMPAD8 小键盘 8 键0x68VK_NUMPAD9 小键盘 9 键0x69VK_F1 - VK_F24 功能键F1 – F24 0x70 - 0x87VK_NUMLOCK Num Lock 键0x90VK_SCROLL Scroll Lock 键0x91DIK_0 – DIK_9 数字0 - 9DIK_A – DIK_Z 字母A - ZDIK_F1 – DIK_F12 功能键F1 – F12 DIK_BACK Backspace 键DIK_TAB Tab 键DIK_RETURN 回车键DIK_LSHIFT 左Shift 键DIK_RSHIFT 右Shift 键DIK_LCONTROL 左Ctrl 键DIK_RCONTROL 右Ctrl 键DIK_LMENU 左Alt 键DIK_RMENU 右Alt 键DIK_PAUSE Pause 键DIK_CAPITAL Caps Lock 键DIK_ESCAPE Esc 键DIK_SPACE 空格键DIK_PRIOR Page Up 键DIK_NEXT Page Down 键DIK_END End 键DIK_HOME Home 键DIK_LEFT 左箭头键DIK_UP 上箭头键DIK_RIGHT 右箭头键DIK_DOWN 下箭头键DIK_SYSRQ SysRq键DIK_INSERT Insert 键DIK_DELETE Delete 键DIK_LWIN 左WinKey(104键盘才有) DIK_RWIN 右WinKey(104键盘才有) DIK_APPS AppsKey(104键盘才有) DIK_NUMPAD0 – DIK_NUMPAD0 小键盘0 – 9 键DIK_NUMLOCK Num Lock 键DIK_SCROLL Scroll Lock 键。

CC++使用keybd_event模拟键盘按键

CC++使用keybd_event模拟键盘按键

CC++使⽤keybd_event模拟键盘按键1 #include <stdio.h>2 #include <Windows.h>34/*5设置键盘⼤⼩写状态6 big:为TRUE则切换⼤写状态,否则切换⼩写状态7*/8 VOID MySetKeyBig(BOOL big = FALSE);910/*11模拟键盘按键,⽀持⼤⼩写12 str:需要按出的字符串13*/14 VOID MyAnalogKey(char *str);1516int main(void)17 {18// 当程序运⾏1.5s时再执⾏模拟按键,以便选择需要操作的窗⼝19 Sleep(1500);20 MyAnalogKey("Love life,Love BiaoGe.0123456789");21 system("pause");22return0;23 }2425 VOID MySetKeyBig(BOOL big)26 {27// 判断键盘CapsLock键是否开启状态,开启状态则为⼤写,否则为⼩写28if (GetKeyState(VK_CAPITAL))29 {30// 如果当前键盘状态为⼤写,要求改⼩写,则模拟按键CapsLock切换状态31if (!big)32 {33 keybd_event(VK_CAPITAL, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);34 keybd_event(VK_CAPITAL, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);35 }36 }37else38 {39// 如果当前键盘状态为⼩写,要求改⼤写,则模拟按键CapsLock切换状态40if (big)41 {42 keybd_event(VK_CAPITAL, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);43 keybd_event(VK_CAPITAL, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);44 }45 }46 }4748 VOID MyAnalogKey(char *str)49 {50int iLen = 0;51char *tmp = NULL;52 INPUT *keys = NULL;53 BOOL bOldState = FALSE;5455// 保存此操作前的键盘状态56 bOldState = (BOOL)GetKeyState(VK_CAPITAL);57 iLen = lstrlen(str);58 tmp = (char *)malloc(iLen);59 memmove(tmp, str, iLen);60for (int i = 0; i < iLen; i++)61 {62// 某些符号⾮直属键盘按键,这⾥只过滤转换两个,以后⽤到其它字符⾃⾏添加过滤63if (tmp[i] == '')64 {65// 产⽣⼀个击键消息步骤:按下->抬起66 keybd_event(VK_SPACE, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);67 keybd_event(VK_SPACE, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);68 }69else if (tmp[i] == ',')70 {71 keybd_event(VK_OEM_COMMA, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);72 keybd_event(VK_OEM_COMMA, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);73 }74else if (tmp[i] >= 'a' && tmp[i] <= 'z')75 { // 根据字符⼤⼩写切换键盘⼤⼩写状态76 MySetKeyBig(0);77// keybd_event只识别⼤写78 keybd_event((BYTE)tmp[i]-32, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);79 keybd_event((BYTE)tmp[i]-32, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);80 }81else if ((tmp[i] >= 'A' && tmp[i] <= 'Z') || (tmp[i] >= '0' && tmp[i] <= '9'))82 {83 MySetKeyBig(1);84 keybd_event((BYTE)tmp[i], NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);85 keybd_event((BYTE)tmp[i], NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);86 }87else88 {89 keybd_event((BYTE)tmp[i]+64, NULL, KEYEVENTF_EXTENDEDKEY | 0, NULL);90 keybd_event((BYTE)tmp[i]+64, NULL, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, NULL);91 }92 }93// 恢复此操作之前的键盘状态94 MySetKeyBig(bOldState);95free(tmp);96 }。

用keybd_event在WINCE下实现按键功能

用keybd_event在WINCE下实现按键功能

用keybd_event在WINCE下实现按键功能在Windows CE(WINCE)下,可以使用keybd_event函数来实现按键功能。

keybd_event函数会模拟键盘事件,包括按下和释放键盘上的按键。

keybd_event函数的原型如下:VOID keybd_eventBYTEbVk,BYTE bScan,DWORD dwFlags,DWORD dwExtraInfo其中,参数bVk指定了要模拟的键盘按键的虚拟键码,bScan指定了与按键关联的硬件扫描码,dwFlags指定了按键事件的标志,dwExtraInfo指定了与事件关联的附加信息。

要使用keybd_event函数实现按键功能,可以按照以下步骤进行:1. 获取要模拟的按键的虚拟键码。

可以使用GetAsyncKeyState函数来获取当前按下的键的虚拟键码。

例如,获取按下的A键的虚拟键码可以使用如下代码:BYTEbVk=VK_A;2. 调用keybd_event函数模拟按下键盘按键。

设置dwFlags参数为KEYEVENTF_EXTENDEDKEY , KEYEVENTF_KEYDOWN来模拟按下键盘按键。

例如,模拟按下A键可以使用如下代码:keybd_event(bVk, 0, KEYEVENTF_EXTENDEDKEY ,KEYEVENTF_KEYDOWN, 0);3. 延迟一段时间,模拟按键的持续时间。

可以使用Sleep函数来延迟一定的时间,以模拟按键的持续时间。

例如,延迟100毫秒可以使用如下代码:Sleep(100);4. 调用keybd_event函数模拟释放键盘按键。

设置dwFlags参数为KEYEVENTF_EXTENDEDKEY , KEYEVENTF_KEYUP来模拟释放键盘按键。

例如,模拟释放A键可以使用如下代码:keybd_event(bVk, 0, KEYEVENTF_EXTENDEDKEY , KEYEVENTF_KEYUP, 0);通过以上步骤,就可以使用keybd_event函数在Windows CE下实现按键功能。

模拟按键的话还比较简单

模拟按键的话还比较简单

如果你是想模拟按键的话还比较简单,一种方法是用keybd_event 来模拟,给个例子:Option ExplicitPrivate Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)Private Const VK_ADD As Long = &H6B '加号键Private Const VK_APPS As Long = &H5D 'Applications 键(相当于鼠标右键)Private Const VK_BACK As Long = &H8 'BackSpace 键Private Const VK_CAPITAL As Long = &H14 'Caps Lock 键(大小写转换键)Private Const VK_CANCEL As Long = &H3 'Ctrl + Break 过程Private Const VK_CONTROL As Long = &H11Private Const VK_DECIMAL As Long = &H6E '小数点号键Private Const VK_DELETE As Long = &H2EPrivate Const VK_DIVIDE As Long = &H6F '除号键Private Const VK_DOWN As Long = &H28Private Const VK_END As Long = &H23Private Const VK_ESCAPE As Long = &H1BPrivate Const VK_F1 As Long = &H70Private Const VK_F10 As Long = &H79Private Const VK_F11 As Long = &H7APrivate Const VK_F12 As Long = &H7BPrivate Const VK_F2 As Long = &H71Private Const VK_F3 As Long = &H72Private Const VK_F4 As Long = &H73Private Const VK_F5 As Long = &H74Private Const VK_F6 As Long = &H75Private Const VK_F7 As Long = &H76Private Const VK_F8 As Long = &H77Private Const VK_F9 As Long = &H78Private Const VK_HOME As Long = &H24Private Const VK_INSERT As Long = &H2DPrivate Const VK_LCONTROL As Long = &HA2Private Const VK_LEFT As Long = &H25Private Const VK_LMENU As Long = &HA4 '左Alt 键Private Const VK_LSHIFT As Long = &HA0Private Const VK_LWIN As Long = &H5BPrivate Const VK_MENU As Long = &H12 'Alt 键Private Const VK_MULTIPLY As Long = &H6A '乘号键Private Const VK_NEXT As Long = &H22 '下翻页键Private Const VK_NUMLOCK As Long = &H90Private Const VK_NUMPAD0 As Long = &H60Private Const VK_NUMPAD1 As Long = &H61Private Const VK_NUMPAD2 As Long = &H62Private Const VK_NUMPAD3 As Long = &H63Private Const VK_NUMPAD4 As Long = &H64Private Const VK_NUMPAD5 As Long = &H65Private Const VK_NUMPAD6 As Long = &H66Private Const VK_NUMPAD7 As Long = &H67Private Const VK_NUMPAD8 As Long = &H68Private Const VK_NUMPAD9 As Long = &H69Private Const VK_PAUSE As Long = &H13Private Const VK_PRINT As Long = &H2APrivate Const VK_PRIOR As Long = &H21 '上翻页键Private Const VK_RCONTROL As Long = &HA3Private Const VK_RETURN As Long = &HD '回车键Private Const VK_RIGHT As Long = &H27Private Const VK_RMENU As Long = &HA5 '右Alt 键Private Const VK_RSHIFT As Long = &HA1Private Const VK_RWIN As Long = &H5CPrivate Const VK_SCROLL As Long = &H91 'Scroll Lock 键Private Const VK_SEPARATOR As Long = &H6C '小键盘上的回车键Private Const VK_SHIFT As Long = &H10Private Const VK_SLEEP As Long = &H5F '休眠键Private Const VK_SNAPSHOT As Long = &H2C 'Print Screen 键Private Const VK_SPACE As Long = &H20Private Const VK_SUBTRACT As Long = &H6D '减号键Private Const VK_TAB As Long = &H9Private Const VK_UP As Long = &H26Private Const VK_OEM_1 As Long = &HBA 'Windows 2000:对于US 标准键盘,是“;:”键Private Const VK_OEM_2 As Long = &HBF 'Windows 2000:对于US 标准键盘,是“/?”键Private Const VK_OEM_3 As Long = &HC0 'Windows 2000:对于US 标准键盘,是“`~”键Private Const VK_OEM_4 As Long = &HDB 'Windows 2000:对于US 标准键盘,是“[{”键Private Const VK_OEM_5 As Long = &HDC 'Windows 2000:对于US 标准键盘,是“\|”键Private Const VK_OEM_6 As Long = &HDD 'Windows 2000:对于US 标准键盘,是“]}”键Private Const VK_OEM_7 As Long = &HDE 'Windows 2000:对于US 标准键盘,是“单/双引号”键Private Const VK_OEM_COMMA As Long = &HBC 'Windows 2000:对于任何国家/地区,是“,”键Private Const VK_OEM_MINUS As Long = &HBD 'Windows 2000:对于任何国家/地区,是“-”键Private Const VK_OEM_PERIOD As Long = &HBE 'Windows 2000:对于任何国家/地区,是“.”键Private Const VK_OEM_PLUS As Long = &HBB 'Windows 2000:对于任何国家/地区,是“+”键Private Const KEYEVENTF_KEYUP = &H2'根据指定的映射类型,执行不同的扫描码和字符转换,0——wCode是个虚拟键码。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

键盘虚拟键值编码表使用keybd_Event
也是在cnblogs上找的,怕到时忘了,先记下来
原文章:/nemolog/archive/2005/10/30/265035.ht ml
模拟键盘输入首先要用到一个API函数:keybd_event。

我们是菜鸟,所以不必具体去理解它的详细用法,只要按以下方法使用即可了!呵呵!
模拟按键有两个基本动作,即按下键和放开按键,所以我们每模拟一次按键就要调用两次该API函数,其方法是:
例子1:模拟按下'A'键
keybd_event(65,0,0,0);
keybd_event(65,0,KEYEVENTF_KEYUP,0);
例子2:模拟按下'ALT+F4'键
keybd_event(18,0,0,0);
keybd_event(115,0,0,0);
keybd_event(115,0,KEYEVENTF_KEYUP,0);
keybd_event(18,0,KEYEVENTF_KEYUP,0);
例子3:在启动一个程序之前清空屏幕(按Win +D)
[DllImport("User32.dll")]
public static extern void keybd_event(Byte bVk, Byte bScan, Int32 dwFlags, Int32 dwEx traInfo);
keybd_event(0x5b, 0, 0, 0);
keybd_event(68, 0, 0, 0);
keybd_event(0x5b, 0, 0x2, 0);
keybd_event(68, 0, 0x2, 0);
附:常用模拟键的键值对照表。

键盘键与虚拟键码对照表
字母和数字键数字小键盘的键功能键其它键
键键码键键码键键码键
键码
A650 96 F1 112 Backspace 8
B66197 F2 113Tab 9
C67 2 98 F3 114Clear
12
D68399 F4 115Enter
13
E69 4 100 F5 116Shift
16
F70 5 101 F6 117Control
17
G71 6102 F7 118 Alt
18
H72 7 103 F8 119Caps Lock
20
I73 8 104F9 120Esc
27
J74 9105F10121Spacebar
32
K75 * 106F11122Page Up
33
L76 + 107F12123Page Down
34
M77 Enter 108-- --End
35
N78 - 109-- -- Home
36
O79 . 110---- Left Arrow 37
P80 / 111---- Up Arrow
38
Q81 -- ------ Right Arrow 39
R82 -- ------ Down Arrow 40
S83 -- ---- -- Insert
45
T84 -- ------ Delete
46
U85 -- ---- -- Help
47
V86 ------ -- Num Lock
144
W87
X88
Y89
Z90
048
149
250
351
452
553
654
755
856
957
----------------------------------
与键盘上各键对应的键值
在软件开发的过程中我们经常与键盘打交道,以下是我查MSDN 所得希望对各位有帮助。

可在代码中的任何地方用下列值代替键盘上的键:
值描述
0x1 鼠标左键
0x2 鼠标右键
0x3 CANCEL 键
0x4 鼠标中键
0x8 BACKSPACE 键
0x9 TAB 键
0xC CLEAR 键
0xD ENTER 键
0x10 SHIFT 键
0x11 CTRL 键
0x12 MENU 键
0x13 PAUSE 键
0x14 CAPS LOCK 键
0x1B ESC 键
0x20 SPACEBAR 键
0x21 PAGE UP 键
0x22 PAGE DOWN 键
0x23 END 键
0x24 HOME 键
0x25 LEFT ARROW 键
0x26 UP ARROW 键
0x27 RIGHT ARROW 键
0x28 DOWN ARROW 键
0x29 SELECT 键
0x2A PRINT SCREEN 键
0x2B EXECUTE 键
0x2C SNAPSHOT 键
0x2D INSERT 键
0x2E DELETE 键
0x2F HELP 键
0x90 NUM LOCK 键
A 至Z 键与A - Z 字母的ASCII 码相同:值描述
65 A 键
66 B 键
67 C 键
68 D 键
69 E 键
70 F 键
71 G 键
72 H 键
73 I 键
74 J 键
75 K 键
76 L 键
77 M 键
78 N 键
79 O 键
80 P 键
81 Q 键
82 R 键
83 S 键
84 T 键
85 U 键
86 V 键
87 W 键
88 X 键
89 Y 键
90 Z 键
0 至9 键与数字0 - 9 的ASCII 码相同:值描述
48 0 键
49 1 键
50 2 键
51 3 键
52 4 键
53 5 键
54 6 键
55 7 键
56 8 键
57 9 键
下列常数代表数字键盘上的键:
值描述
0x60 0 键
0x61 1 键
0x62 2 键
0x63 3 键
0x64 4 键
0x65 5 键
0x66 6 键
0x67 7 键
0x68 8 键
0x69 9 键
0x6A MULTIPLICATION SIGN (*) 键0x6B PLUS SIGN (+) 键
0x6C ENTER 键
0x6D MINUS SIGN (-) 键
0x6E DECIMAL POINT (.) 键
0x6F DIVISION SIGN (/) 键
下列常数代表功能键:
值描述
0x70 F1 键
0x71 F2 键
0x72 F3 键
0x73 F4 键
0x74 F5 键
0x75 F6 键
0x76 F7 键
0x77 F8 键
0x78 F9 键0x79 F10 键0x7A F11 键0x7B F12 键0x7C F13 键0x7D F14 键0x7E F15 键0x7F F16 键。

相关文档
最新文档