#include #include #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x... 刚打开软件时需要输入按键事件之间的时间延迟,单位是ms。
#include
#include
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
int main(void)
{
POINT pt;
int i;
int delaytime;
int keynum;
printf("input the delay time(ms):");
scanf("%d",&delaytime);
while(1)
{
switch (KEYDOWN(VK_ESCAPE))
{
case 1:
{
while (!KEYDOWN(VK_RETURN ))
{
Sleep(10);
}
break;
}
case 0:
{
//VK_NUMLOCK
//VK_SPACE
keybd_event(VK_NUMLOCK , 0, 0, 0);
Sleep(delaytime/2);
keybd_event(VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0);
Sleep(delaytime/2);
break;
}
}
}
return 0;
}
主要是用到了keybd_event(VK_NUMLOCK , 0, 0, 0);这个函数。