C++鼠标连点,按下F2开始整活
#include <iostream>
#include <Windows.h> //windows系统库,鼠标点击、按键和时差需要用到
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //点击信号获取
int main ( ) {
//循环判断点击
while ( 1 ) {
while ( KEY_DOWN ( VK_F2 ) || KEY_DOWN ( VK_F2 ) ) { //判断是否按下F2开始循环,*设置按键
mouse_event ( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); //模拟鼠标左键按下信号
mouse_event ( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); //模拟鼠标左键弹起信号
}
Sleep ( 20 ); //等待20ms,*设置间隔时间
}
//循环判断结束
return 0;
}