首页 > 其他分享 >MouseClicker v7.0

MouseClicker v7.0

时间:2023-06-17 22:45:19浏览次数:62  
标签:ch v7.0 pos cy MouseClicker printf lx ly

Mouse Clicker v8.0 Beta

By Haozexu

At 2022/8/12 20:16

原创程序,转载请注明出处。

LICENSE:GPL 3.0

项目地址

更新日志 Update Log

  • 修复mode 3
  • 添加无限连点
  • 添加区间连点模式
  • 增强用户体验
  • 测试:长按模式

专用更新器

您也可以上Gitee去自己下载安装包

  • 使用安装器时,请用管理员方式启动。
  • 如果要自己编译,记得添加链接器选项 -lurlmon -lwininet
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
using namespace std;
DWORD slp=10;
int mode=1;
long long cs=0;
long long x,y,sx,sy,ex,ey,tot,onoff=1,utim[1000005],whl[1000005];
tagPOINT rec[1000005];bool lr[1000005],lrp=1,hide=0,top=0;
long long getrnd(long long a,long long b){
    if(a>b) swap(a,b);
    return rand() % (b-a+1)+ a;
}
char *word[9]={"","连续点击","点一次附带几次","固定位置点击","固定次数点击","随机范围点击","鼠标录制模式","固定区域开关","长按模式"};
int main(){
    system("title Mouse Clicker v7.0 -by Haozexu");
    printf("Mouse Clicker v7.0\n按ESC开始连点\n按左SHIFT停止连点\n按右SHIFT打开设置\n");
    while(1){
        if(GetKeyState(VK_ESCAPE)<0){
            printf("正在使用连点模式[%s].",word[mode]);
            if(hide){
                SetWindowPos(GetConsoleWindow(),HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
            }
            switch(mode){
                case 1:
                    while(1){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                    break;
                case 2:
                    while(1){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        if(GetKeyState(VK_LBUTTON)<0){
                            for(long long i=1;i<=cs;i++){
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                                mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                Sleep(slp);
                            }
                        }
                        if(GetKeyState(VK_RBUTTON)<0){
                            for(long long i=1;i<=cs;i++){
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                                mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                Sleep(slp);
                            }
                        }
                    }
                    break;
                case 3:
                    for(long long i=1;i<=cs||cs==-1;i++){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        SetCursorPos(x,y);
                        if(lrp){
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                        }else{
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                        }
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                    break;
                case 4:
                    for(long long i=1;i<=cs||cs==-1;i++){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        if(lrp){
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                        }else{
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                        }
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                    break;
                case 5:
                    srand(time(NULL));
                    for(long long i=1;i<=cs||cs==-1;i++){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        SetCursorPos(getrnd(sx,ex),getrnd(sy,ey));
                        if(lrp){
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                        }else{
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                            mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                        }
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                    break;
                case 6:
                    for(long long i=1;i<=cs||cs==-1;i++){
                        bool flg=0;
                        for(int j=1;j<=tot;j++){
                            if(GetKeyState(VK_LSHIFT)<0){
                                flg=1;
                                break;
                            }
                            SetCursorPos(rec[j].x,rec[j].y);
                            if(lr[i]){
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                                Sleep(utim[j]+cs);
                                mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                            }else{
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                                Sleep(utim[j]+cs);
                                mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                            }
                            if(GetKeyState(VK_LSHIFT)<0) break;
                            Sleep(slp); 
                        }
                        if(flg) break;
                    }
                    break;
                case 7:
                    while(1){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        POINT pt;
                        GetCursorPos(&pt);
                        if(onoff){
                            if((sx<=pt.x&&pt.x<=ex&&sy<=pt.y&&pt.y<=ey)){
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                if(lrp){
                                    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                                    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                                }else{
                                    mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                                    mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                                }
                            }   
                        }else{
                            if(!(sx<=pt.x&&pt.x<=ex&&sy<=pt.y&&pt.y<=ey)){
                                if(GetKeyState(VK_LSHIFT)<0) break;
                                if(lrp){
                                    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
                                    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);    
                                }else{
                                    mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                                    mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                                }
                            }
                        }
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                case 8:
				if(lrp){
                    mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); 
                }else{
                    mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
                }
                	while(1){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        Sleep(slp);
                    }
                    mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
                    mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
					break; 
                default:
                    printf("未定义的模式!\n");
                    system("pause");
                    break;
            }
            if(hide){
                SetWindowPos(GetConsoleWindow(),HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
                if(top) SetWindowPos(GetConsoleWindow(),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
            }
            system("cls");
            printf("Mouse Clicker v7.0\n按ESC开始连点\n按左SHIFT停止连点\n按右SHIFT打开设置\n");
        }
        if(GetKeyState(VK_RSHIFT)<0){
            printf("窗口大小?(单位像素,输入-1 -1表示不做修改)");
            long long clx,cly;
            cin>>clx>>cly;
            if(!(clx==cly&&clx==-1)){
                if(clx<0||cly<0){
                    printf("大小太小!");
                    system("pause");
                }else{
                    SetWindowPos(GetConsoleWindow(),HWND_TOPMOST,0,0,clx,cly,SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
                }
            }
            printf("连点时自动隐藏窗口?(y/ANYKEY)");
            char ch;cin>>ch;
            if(ch=='y'){
                hide=1;
            }else hide=0;
            printf("窗口置顶?(y/ANYKEY)");
            cin>>ch;
            if(ch=='y'){
                top=1;
                SetWindowPos(GetConsoleWindow(),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
            }else{
                top=0;
                SetWindowPos(GetConsoleWindow(),HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
            }
            printf("两次连点之间的时间间隔[单位精确到ms]?");
            int sl;cin>>sl;
            if(sl<10){
                printf("间隔太小!\n");
                system("pause");
                system("cls");
                printf("Mouse Clicker v7.0\n按ESC开始连点\n按左SHIFT停止连点\n按右SHIFT打开设置\n");
                continue;   
            }
            printf("-----模式清单-----\n");
            printf("序号   描述\n");
            for(int i=1;i<=8;i++){
                printf("%d  %s\n",i,word[i]);
            }
            printf("模式?");
            cin>>mode;long long lx,ly;
            int cx,cy;
            switch(mode){
                case 1:
                    break;
                case 2:
                    printf("点一次附带几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    break;
                case 3:
                    printf("在哪里点击(x,y格式;特别地,输入-1 -1来表示在当前位置点击)?");
                    cin>>lx>>ly;
                    if(lx==ly&&lx==-1){
                        POINT pos;
                        GetCursorPos(&pos);
                        lx=x=pos.x;ly=y=pos.y;
                    }
                    cx=GetSystemMetrics(SM_CXSCREEN);   
                    cy=GetSystemMetrics(SM_CYSCREEN);
                    if(lx<0||ly<0||lx>cx||ly>cy){
                        printf("超出屏幕边界!\n您的屏幕大小为%d*%d\n",cx,cy);
                        system("pause");
                        break;
                    }
                    x=lx,y=ly;
                    printf("固定点击几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    printf("左/右键?[l,ANYKEY]");
                    cin>>ch;
                    if(ch=='l') lrp=1;
                    else lrp=0;
                    break;
                case 4:
                    printf("固定点击几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    printf("左/右键?[l,ANYKEY]");
                    cin>>ch;
                    if(ch=='l') lrp=1;
                    else lrp=0;
                    break;
                case 5:
                    printf("要在哪个区域内随机?\n");
                    printf("输入左上起始点的xy坐标(特别地,输入-1 -1表示使用当前鼠标位置)");
                    cin>>lx>>ly;
                    if(lx==ly&&lx==-1){
                        POINT pos;
                        GetCursorPos(&pos);
                        lx=sx=pos.x;ly=sy=pos.y;
                    }
                    cx=GetSystemMetrics(SM_CXSCREEN);   
                    cy=GetSystemMetrics(SM_CYSCREEN);
                    if(lx<0||ly<0||lx>cx||ly>cy){
                        printf("超出屏幕边界!\n您的屏幕大小为%d*%d\n您的输入%d*%d\n",cx,cy,sx,sy);
                        system("pause");
                        break;
                    }
                    sx=lx,sy=ly;
                    printf("输入右下结束点的xy坐标(特别地,输入-1 -1表示使用当前鼠标位置)");
                    cin>>lx>>ly;
                    if(lx==ly&&lx==-1){
                        POINT pos;
                        GetCursorPos(&pos);
                        lx=ex=pos.x;ly=ey=pos.y;
                    }
                    cx=GetSystemMetrics(SM_CXSCREEN);   
                    cy=GetSystemMetrics(SM_CYSCREEN);
                    if(lx<0||ly<0||lx>cx||ly>cy){
                        printf("超出屏幕边界!\n您的屏幕大小为%d*%d\n您的输入%d*%d\n",cx,cy,ex,ey);
                        system("pause");
                        break;
                    }
                    ex=lx,ey=ly;
                    printf("固定点击几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    printf("左/右键?[l,ANYKEY]");
                    cin>>ch;
                    if(ch=='l') lrp=1;
                    else lrp=0;
                    if(sx>ex) swap(sx,sy);
                    if(sy>ey) swap(sy,ey);
                    printf("您的范围(%d,%d)-(%d,%d)\n",sx,sy,ex,ey);
                    system("pause"); 
                    break;
                case 6:
                    printf("按ESC开始录制[仅支持左右键录制]\n");
                    while(1){
                        if(GetKeyState(VK_ESCAPE)<0) break; 
                    }   
                    tot=0;
                    printf("按左SHIFT停止录制[按鼠标左/右键记录一个点]");
                    while(1){
                        if(GetKeyState(VK_LSHIFT)<0) break;
                        if(GetKeyState(VK_LBUTTON)<0){
                            POINT pos;GetCursorPos(&pos);
                            rec[++tot].x=pos.x;
                            rec[tot].y=pos.y;
                            lr[tot]=1;
                            while(GetKeyState(VK_LBUTTON)&0x8000){
                                utim[tot]++;
                                Sleep(1);
                            }
                        }
                        if(GetKeyState(VK_RBUTTON)<0){
                            POINT pos;GetCursorPos(&pos);
                            rec[++tot].x=pos.x;
                            rec[tot].y=pos.y;
                            lr[tot]=0;
                            while(GetKeyState(VK_RBUTTON)&0x8000){
                                utim[tot]++;
                                Sleep(1);
                            }
                        }
                        Sleep(10);
                        if(tot>1000000){
                            printf("记录达上限!\n");
                            MessageBox(0,"记录达上限!","Mouse Clicker v7.0 提示",MB_OK);
                            system("pause");
                            break;
                        }
                    }
                    printf("---记录---\n");
                    for(int i=1;i<=tot;i++){
                        cout<<rec[i].x<<" "<<rec[i].y<<" "<<" "<<utim[i]<<" "<<lr[i]<<endl;
                    }
                    printf("\n重复做几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    break;
                case 7:
                    printf("要在哪个区域内点击?\n");
                    printf("输入左上起始点的xy坐标(特别地,输入-1 -1表示使用当前鼠标位置)");
                    cin>>lx>>ly;
                    if(lx==ly&&lx==-1){
                        POINT pos;
                        GetCursorPos(&pos);
                        lx=sx=pos.x;ly=sy=pos.y;
                    }
                    cx=GetSystemMetrics(SM_CXSCREEN);   
                    cy=GetSystemMetrics(SM_CYSCREEN);
                    if(lx<0||ly<0||lx>cx||ly>cy){
                        printf("超出屏幕边界!\n您的屏幕大小为%d*%d\n您的输入%d*%d\n",cx,cy,sx,sy);
                        system("pause");
                        break;
                    }
                    sx=lx,sy=ly;
                    printf("输入右下结束点的xy坐标(特别地,输入-1 -1表示使用当前鼠标位置)");
                    cin>>lx>>ly;
                    if(lx==ly&&lx==-1){
                        POINT pos;
                        GetCursorPos(&pos);
                        lx=ex=pos.x;ly=ey=pos.y;
                    }
                    cx=GetSystemMetrics(SM_CXSCREEN);   
                    cy=GetSystemMetrics(SM_CYSCREEN);
                    if(lx<0||ly<0||lx>cx||ly>cy){
                        printf("超出屏幕边界!\n您的屏幕大小为%d*%d\n您的输入%d*%d\n",cx,cy,ex,ey);
                        system("pause");
                        break;
                    }
                    ex=lx,ey=ly;
                    printf("固定点击几次(特别地,-1表示无限制)?");
                    cin>>cs;
                    if(cs<-1){
                        cs=0;
                        printf("次数不可为负数!\n");
                        system("pause");
                        break;
                    }
                    printf("左/右键?[l,ANYKEY]");
                    cin>>ch;
                    if(ch=='l') lrp=1;
                    else lrp=0;
                    if(sx>ex) swap(sx,sy);
                    if(sy>ey) swap(sy,ey);
                    printf("您的范围(%d,%d)-(%d,%d)\n",sx,sy,ex,ey);
                    printf("在范围内开启/关闭(o/ANYKEY)?");
                    cin>>ch;
                    if(ch=='o'){
                        onoff=1;
                    }else{
                        onoff=0;
                    }
                    break; 
				case 8:
					printf("左/右键?[l,ANYKEY]");
                    cin>>ch;
                    if(ch=='l') lrp=1;
                    else lrp=0;   
					break;          
                default:
                    printf("模式不存在!\n");
                    system("pause");
                    break;
            }
            slp=sl;
            system("cls");
            printf("Mouse Clicker v7.0\n按ESC开始连点\n按左SHIFT停止连点\n按右SHIFT打开设置\n");
        }
    }
}

Bug & Feature

请发在评论区
或者Pull Issues

Others

点个赞吧。\(QwQ\)

标签:ch,v7.0,pos,cy,MouseClicker,printf,lx,ly
From: https://www.cnblogs.com/haozexu/p/17488422.html

相关文章