c++实现连点器

本期为大家收集了四个用c++实现连点器的程序(非常好用)

首先是@LiJoQiao提供的第一个版本,能实现连点鼠标左键

#include<cstdio>  
#include<windows.h>    
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)   
#define click mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0)
long long N=10000000;
void tj()
{
	system("cls");
	printf("输入速度(win10建议10000000,win7建议1500000;v=10000000时,CPS=60左右):");
	scanf("%lld ",&N); 
	system("cls");
}
void work()
{
	int now=0,k=0;
	bool flag=1; 
	while(1)
	{    
		if(now==1)click;
		if(KEY_DOWN('1')&&flag)now=1;   
	    if(KEY_DOWN('2')&&flag)now=0;    
		if(KEY_DOWN('3')){flag=0;now=0;}
		if(KEY_DOWN('4')){now=0;flag=1;}
		if(KEY_DOWN('5'))tj();
        for(long long i=1;i<=N;++i)k=i+1;  
    }    
}
int main()
{ 
    printf("按1点击左键,按2停止,按3锁定,按4解锁,按5调速\n");  
    work(); 
    return 0;  
}

然后是@Zimse提供的第二个版本,在第一个版本的使用体验上有所升级

#include <iostream>
#include <cstdio>
#include <windows.h>
#include <ctime>
#include <cstdlib> 

using namespace std;

const char Edition[100]="Zimse Auto Click System23 1.3.04";
int cps=50,up,down; 

int main(){
	HWND hwndDOS=GetForegroundWindow();
	ShowWindow(hwndDOS,SW_HIDE);
	MoveWindow(hwndDOS,150,150,400,300,true);
	
	MessageBox(NULL,"\n\t按左箭头查看帮助",Edition,MB_OK);
    srand(time(0));
    
    while(1){
    	if(GetAsyncKeyState(VK_UP)){
    		while(1){
				/*if(GetAsyncKeyState(VK_UP)){
    				++up;
    				if(up>20&&cps<900)++cps,up=0;
				}
				
				if(GetAsyncKeyState(VK_DOWN)){
    				++down;
    				if(down>20&&cps>10)--cps,down=0;
				}*/ 
    			mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
    			if(GetAsyncKeyState(VK_DOWN))break;
    			
    			Sleep(1000/cps);
			}
		}
		
		if(GetAsyncKeyState(VK_LEFT)){
    		ShowWindow(hwndDOS,SW_RESTORE);
    		system("cls");
    		printf("\n\t基本操作:上箭头开始,下箭头停止\n\n\t右箭头退出,左箭头查看帮助\n\n\t请输入新的cps:"); 
    		scanf("%d",&cps);
    		ShowWindow(hwndDOS,SW_HIDE);
		}
		
		if(GetAsyncKeyState(VK_RIGHT))break;
	}
	
	MessageBox(NULL,"\n\t成功退出",Edition,MB_OK);
    return 0;
}

然后是@Coders提供的支持鼠标右键的版本

#include <cstdio>
#include <conio.h>
#include <ctime>
#include <windows.h>
#include <vector>
#include <string>
using namespace std; 
void set_cursor(bool hide) { // 隐藏/显示 光标
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo); // 获取控制台光标信息
	CursorInfo.bVisible = hide;				   // 隐藏控制台光标
	SetConsoleCursorInfo(handle, &CursorInfo); // 设置控制台光标状态
}
void gotoxy(int x, int y) { // 设置光标
	COORD c = {(SHORT)x, (SHORT)y};
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void setmode() {
	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
	DWORD mode;
	GetConsoleMode(hStdin, &mode);
	mode &= ~ENABLE_QUICK_EDIT_MODE; // 移除快速编辑模式
	// mode &= ~ENABLE_INSERT_MODE;	 // 移除插入模式
	// mode &= ~ENABLE_MOUSE_INPUT;
	SetConsoleMode(hStdin, mode);
}
struct Click {
	int x, y;
	int delay;
	int button_down, button_up;
	std::string msg;
};
int main() {
	setmode();
	std::printf("欢迎使用鼠标连点器!\n\n");
_ReStart_: // 重新开始的地方
	system("mode con cols=40 lines=15");
	set_cursor(true);
	SetWindowPos(GetConsoleWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // 窗口置顶
	std::puts("请选择模式:");
	std::puts("  1. 点击位置为鼠标指针,鼠标左/右键点击");
	std::puts("  2. 点击位置固定循环,鼠标左/右键点击");
	std::puts("  0. 退出");
	int ch = _getch();
	while(ch < '0' || ch > '2') ch = _getch();
	system("cls");
	set_cursor(false);
	if(ch == '1') {
		set_cursor(true);
		std::puts("配置:");
		std::printf("请输入每秒钟的点击次数(1—1000):");
		int spd;
		std::scanf("%d", &spd);
		std::printf("\n请选择点击的键(0左键,1右键):");
		ch = _getch();
		while(ch < '0' || ch > '1') ch = _getch();
		int CLICK_BUTTON_DOWN = (ch == '0' ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN);
		int CLICK_BUTTON_UP = (ch == '0' ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP);
		system("cls");
		int cont = true, lst_tim = clock();
		set_cursor(false);
		while(true) {
			gotoxy(0, 0);
			std::printf("连点器%s. . . \n\n", cont ? "运行中" : "已暂停");
			std::printf("速度:%d次/秒\n", spd);
			std::printf("  空格键\t%s\n", cont ? "暂停" : "继续");
			std::printf("  Esc键 \t退出\n");
			SetWindowPos(GetConsoleWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // 窗口置顶
			if(_kbhit()) {
				int ch = _getch();
				if(ch == 27) { // Esc
					break;
				} else if(ch == ' ') { // 空格
					cont = !cont;
				}
			} else {
				if(cont) {
					if(clock() - lst_tim >= 1.0 / spd * CLOCKS_PER_SEC) {
						lst_tim = clock();
						POINT pt;
						GetCursorPos(&pt);
						mouse_event(CLICK_BUTTON_DOWN, 0, 0, 0, 0);
						mouse_event(CLICK_BUTTON_UP, 0, 0, 0, 0);
					}
				}
			}
		}
	} else if(ch == '2') {
		std::printf("请输入您要点击的位置个数:");
		int times;
		std::scanf("%d", &times);
		std::vector<Click> ps;
		set_cursor(true);
		for(int i = 1; i <= times; i++) {
			system("cls");
			std::printf("将鼠标移动到第%d个位置上后按下空格:", i);
			while(_getch() != ' ') {}
			POINT p;
			GetCursorPos(&p);
			ps.push_back({p.x, p.y, 0, 0, 0, ""});
			std::printf("\n需要按下的键(0左键,1右键):");
			char ch = _getch();
			while(ch < '0' || ch > '1') ch = _getch();
			ps.back().button_down = (ch == '0' ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN);
			ps.back().button_up = (ch == '0' ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP);
			std::printf("\n在上一次点击后需要等待多少毫秒:");
			int delay;
			std::scanf("%d", &delay);
			ps.back().delay = delay;
			std::printf("\n附加描述(可不填):");
			char msg[10000];
			gets(msg);
			gets(msg);
			ps.back().msg = msg;
		}
		int cont = true;
		int now = 0;
		int lst_tim = clock();
		system("cls");
		set_cursor(false);
		while(true) {
			gotoxy(0, 0);
			std::printf("连点器%s. . . \n\n", cont ? "运行中" : "已暂停");
			std::printf("当前位置描述:%s\n", ps[now].msg.c_str());
			std::printf("需要等待:%d秒\n", ps[now].delay);
			std::printf("点击按键:%s键\n", (ps[now].button_down == MOUSEEVENTF_LEFTDOWN ? "左" : "右"));
			std::printf("  空格键\t%s\n", cont ? "暂停" : "继续");
			std::printf("  Esc键 \t退出\n");
			SetWindowPos(GetConsoleWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // 窗口置顶
			if(_kbhit()) {
				int ch = _getch();
				if(ch == 27) { // Esc
					break;
				} else if(ch == ' ') { // 空格
					cont = !cont;
				}
			} else {
				if(cont) {
					if(clock() - lst_tim > ps[now].delay) {
						lst_tim = clock();
						POINT pt;
						GetCursorPos(&pt);
						SetCursorPos(ps[now].x, ps[now].y);
						mouse_event(ps[now].button_down, 0, 0, 0, 0);
						mouse_event(ps[now].button_up, 0, 0, 0, 0);
						SetCursorPos(pt.x, pt.y);
						if(now + 1 == (int)ps.size()) now = 0;
						else
							now = now + 1;
					}
				}
			}
		}
	} else
		return 0;
	system("cls");
	std::printf("欢迎回来!\n\n");
	goto _ReStart_;
	return 0;
}

 最后是@incra提供的支持按键的连点器

#include<bits/stdc++.h>
#include<cstdio>
#include<windows.h>
#include<conio.h>
using namespace std;

double times,a=1000;
char key;
int main(){
    printf("请输入准备按下的按键(字母或数字):");
    scanf("%c",&key);
    if(int(key)>='a'&&int(key)<='z')
        key-=32; 
    printf("请输入需求CPS(建议不超过50):");
    scanf("%lf",&times);
    printf("按%c开始连点\n",key);
    double time=a/(times+0.1*times);
    while(true)
    {
        if(GetAsyncKeyState(key))
        {
            mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
            Sleep(time);
        }
    }
    return 0;
}

那今天就到这了,感谢四位大佬,如果有更好的意见欢迎联系小编

完结撒花!!!

  • 5
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hear the Wind Sing.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值