#include <iostream>
#include <thread>
#include <windows.h>
using namespace std;
void mouse_keep_click()
{
POINT p;
HWND hdc;
while (1){
if (GetAsyncKeyState(VK_UP) & 0x8000){
cout<<"鼠标点击开始!"<<endl;
GetCursorPos(&p);
hdc = WindowFromPoint(p);
ScreenToClient(hdc, &p);
while(1){
PostMessage(hdc,WM_LBUTTONDOWN,MK_LBUTTON,MAKELONG(p.x,p.y));
Sleep(10);
PostMessage(hdc,WM_LBUTTONUP,0,MAKELONG(p.x,p.y));
if (GetAsyncKeyState(VK_DOWN) & 0x8000){
cout << "鼠标点击结束!" << endl;
break;
}
}
}
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000){
cout << "程序结束!" << endl;
break;
}
Sleep(20);
}
}
int main()
{
cout << "鼠标连击程序开始启动...." << endl;
cout << "UP启动当前位置鼠标连击,DOWN关闭鼠标连击;ESC退出程序。" << endl;
thread t1 (mouse_keep_click);
t1.join();
return 0;
}
可以用mingw编译器编译,可执行文件87k,非常小巧实用。