|
发表于 2024-8-28 09:41:44
|
显示全部楼层
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
double delay,num,kind,zhong;
char jian;
bool clicking;
void Click(){
if(kind==1){
if(num==1){
mouse_event(MOUSEEVENTF_LEFTDOWN,1,2,0,0);
if(zhong==1)mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
else{
mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
if(zhong==1)mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
}
}
else{
}
}
int main(){
while(1){
clicking=false;
cout<<"请输入操作(1:连点,2:长按):";
cin>>zhong;
while(zhong!=1&&zhong!=2)cout<<"请重新输入",cin>>zhong;
if(zhong==1){
cout<<"请输入间隔(毫秒):";
cin>>delay;
}
cout<<"请输入操作对象(1:鼠标,2:键盘):";
cin>>kind;
while(kind!=1&&kind!=2)cout<<"请重新输入",cin>>kind;
if(kind==1){
cout<<"请输入左键或右键(1:左键,2:右键):";
cin>>num;
while(num!=1&&num!=2)cout<<"请重新输入",cin>>num;
}
else if(kind==2){
cout<<"正在制作中......\n";
continue;
}
cout<<"按'S'键开始,'Q'键结束,'E'键退出\n";
while(1){
if(GetAsyncKeyState('E')&0x8000)break;
if(GetAsyncKeyState('S')&0x8000){
clicking=true;
cout<<"开始\n";
}
if(GetAsyncKeyState('Q')&0x8000){
clicking=false;
cout<<"已停止\n";
}
if(clicking){
Click();
Sleep(delay);
}
this_thread::sleep_for(chrono::milliseconds(10));
}
system("cls");
}
return 0;
}
我的功能更全 |
|