2011-11-18 21:11:40Morris
[C/C++] 模擬鍵盤按鍵 自動回應
虚拟键盘代码 16进制值 对应键
VK_LBUTTON 01 鼠标左键
VK_RBUTTON 02 鼠标右键
VK_CANCEL 03 用于执行Ctrl+C或Ctrl+Break
VK_MBUTTON 04 鼠标中键
VK_BACK 08 Backspace键
VK_TAB 09 Tab键
VK_CLEAR 0C Clear键
VK_RETURN 0D Enter键
VK_SHIFT 10 Shift键
VK_CONTROL 11 Ctrl键
VK_MENU 12 Alt键
VK_PAUSE 13 Pause键
VK_CAPITAL 14 Capslock键
VK_ESCAPE 1B Ese键
VK_SPACE 20 SpaceBar键
VK_PRIOR 21 PgUp键
VK_NEXT 22 PgDn键
VK_END 23 End键
VK_HOME 24 Home键
VK_LEFT 25 Left Arrow键
VK_UP 26 Up Arrow键
VK_RIGHT 27 Right Arrow键
VK_DOWN 28 Down Arrow键
VK_SELECT 29 Select键
VK_EXECUTE 2B Execute键
VK_SNAPSHOT 2C PrintScreen键
VK_INSERT 2D Ins键
VK_DELECT 2E Del键
VK_HELP 2F Help键
VK_0 30 0键
… … …
VK_9 39 9键
VK_A 41 A键
… … …
VK_Z 5A Z键
VK_NUMAPD0 60 数字板0键
… … …
VK_NUMAPD9 69 数字板9键
VK_MULTIPY 6A 乘号键
VK_ADD 6B 加号键
VK_SEPARATOR 6C Separator键
VK_SUBSTRACT 6D 减号键
VK_DECIMAL 6E 小数点键
VK_DIVIDE 6F 除号键
VK_F1 70 F1键
… … …
VK_F24 87 F24键
VK_NUMLOCK 90 NumLock键
VK_SCROLL 91 ScrollLock键
VK_CAPITAL Caps Lock
VK_ESCAPE Esc
VK_SPACE Space
VK_PRIOR Page Up
VK_NEXT Page Down
VK_END End
VK_HOME Home
VK_LEFT 向左方向键
VK_UP
VK_RIGHT
VK_DOWN
VK_DELETE Delete
VK_INSERT Inser
VK_NUMPAD0~VK_NUMPAD9 小键盘上的0-9键
VK_F1-VK_f12 F1-F12键
來源 : http://topic.csdn.net/t/20010725/21/209399.html
看到有人用 FaceBook 挑戰 2147483647 的回應總數, 以下部分來自於社團的文章
#include <windows.h>
#include <time.h>
void wait(int t) {
clock_t endwait;
endwait = clock () + t;
while (clock() < endwait);
}
int main () {
int t = 0;
char s[10][10] = {"j0 ", "su;6", "284", "cl3"};
while(1) {
int timeofinput = rand()%1800+200;
wait(timeofinput);
int i, j, x;
for(i = 0; i < 4; i++) {
for(j = 0; s[i][j]; j++) {
keybd_event(VkKeyScan(s[i][j]), 0, 0, 0);
keybd_event(VkKeyScan(s[i][j]), 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(0x0D, 0, 0, 0);
keybd_event(0x0D, 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(VkKeyScan(' '), 0, 0, 0);
keybd_event(VkKeyScan(' '), 0, KEYEVENTF_KEYUP, 0);
x = rand()%4;
for(i = 0; i < x; i++) {
char c = '!';
keybd_event(VK_LSHIFT, 0, 0, 0);
keybd_event(VkKeyScan(c), 0, 0, 0);
keybd_event(VkKeyScan(c), 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(0x0D, 0, 0, 0);
keybd_event(0x0D, 0, KEYEVENTF_KEYUP, 0);
t++;
if(t == 100) {
wait(30000);
t = 0;
}
}
return 0;
}
VK_LBUTTON 01 鼠标左键
VK_RBUTTON 02 鼠标右键
VK_CANCEL 03 用于执行Ctrl+C或Ctrl+Break
VK_MBUTTON 04 鼠标中键
VK_BACK 08 Backspace键
VK_TAB 09 Tab键
VK_CLEAR 0C Clear键
VK_RETURN 0D Enter键
VK_SHIFT 10 Shift键
VK_CONTROL 11 Ctrl键
VK_MENU 12 Alt键
VK_PAUSE 13 Pause键
VK_CAPITAL 14 Capslock键
VK_ESCAPE 1B Ese键
VK_SPACE 20 SpaceBar键
VK_PRIOR 21 PgUp键
VK_NEXT 22 PgDn键
VK_END 23 End键
VK_HOME 24 Home键
VK_LEFT 25 Left Arrow键
VK_UP 26 Up Arrow键
VK_RIGHT 27 Right Arrow键
VK_DOWN 28 Down Arrow键
VK_SELECT 29 Select键
VK_EXECUTE 2B Execute键
VK_SNAPSHOT 2C PrintScreen键
VK_INSERT 2D Ins键
VK_DELECT 2E Del键
VK_HELP 2F Help键
VK_0 30 0键
… … …
VK_9 39 9键
VK_A 41 A键
… … …
VK_Z 5A Z键
VK_NUMAPD0 60 数字板0键
… … …
VK_NUMAPD9 69 数字板9键
VK_MULTIPY 6A 乘号键
VK_ADD 6B 加号键
VK_SEPARATOR 6C Separator键
VK_SUBSTRACT 6D 减号键
VK_DECIMAL 6E 小数点键
VK_DIVIDE 6F 除号键
VK_F1 70 F1键
… … …
VK_F24 87 F24键
VK_NUMLOCK 90 NumLock键
VK_SCROLL 91 ScrollLock键
VK_CAPITAL Caps Lock
VK_ESCAPE Esc
VK_SPACE Space
VK_PRIOR Page Up
VK_NEXT Page Down
VK_END End
VK_HOME Home
VK_LEFT 向左方向键
VK_UP
VK_RIGHT
VK_DOWN
VK_DELETE Delete
VK_INSERT Inser
VK_NUMPAD0~VK_NUMPAD9 小键盘上的0-9键
VK_F1-VK_f12 F1-F12键
來源 : http://topic.csdn.net/t/20010725/21/209399.html
看到有人用 FaceBook 挑戰 2147483647 的回應總數, 以下部分來自於社團的文章
#include <windows.h>
#include <time.h>
void wait(int t) {
clock_t endwait;
endwait = clock () + t;
while (clock() < endwait);
}
int main () {
int t = 0;
char s[10][10] = {"j0 ", "su;6", "284", "cl3"};
while(1) {
int timeofinput = rand()%1800+200;
wait(timeofinput);
int i, j, x;
for(i = 0; i < 4; i++) {
for(j = 0; s[i][j]; j++) {
keybd_event(VkKeyScan(s[i][j]), 0, 0, 0);
keybd_event(VkKeyScan(s[i][j]), 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(0x0D, 0, 0, 0);
keybd_event(0x0D, 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(VkKeyScan(' '), 0, 0, 0);
keybd_event(VkKeyScan(' '), 0, KEYEVENTF_KEYUP, 0);
x = rand()%4;
for(i = 0; i < x; i++) {
char c = '!';
keybd_event(VK_LSHIFT, 0, 0, 0);
keybd_event(VkKeyScan(c), 0, 0, 0);
keybd_event(VkKeyScan(c), 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
}
keybd_event(0x0D, 0, 0, 0);
keybd_event(0x0D, 0, KEYEVENTF_KEYUP, 0);
t++;
if(t == 100) {
wait(30000);
t = 0;
}
}
return 0;
}
上一篇:[結論] 最少路徑覆蓋問題
灣娘大好
灣娘大好
灣娘大好 !
灣娘大好 !!
灣娘大好
灣娘大好 !!!
灣娘大好 !!
灣娘大好 !!
灣娘大好
灣娘大好 !!!
灣娘大好 !!
灣娘大好 !!!
灣娘大好 !
灣娘大好
灣娘大好 !!!
灣娘大好
灣娘大好
灣娘大好 !
灣娘大好 !!!
灣娘大好 !
灣娘大好 !!
灣娘大好 !!!
灣娘大好 !!
灣娘大好 !!
灣娘大好 !!
灣娘大好
灣娘大好 !
灣娘大好 !
灣娘大好 !!
灣娘大好 !
灣娘大好
灣娘大好 !!!
灣娘大好 !!
灣娘大好
灣娘大好
灣娘大好
灣娘大好 !!!
灣娘大好 !!!
灣娘大好 !!