C++制作一个连点器
今天我下载了一款游戏,还不错,主要是讲的构建地球原始生命的游戏,但是游戏内部的DNA点数需要靠你不断按键取得,有的东西需要十几万DNA点数,但是点一次按键或鼠标只有几十个,仿佛只有单身狗才能做到。所以我就自制了一个连点器,跟大家分享一下。
环境 :
Visual Studio 2019#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
using namespace std;
int main()
{
cout << "进入程序\n";
Sleep(100);
cout << "开发者:GROZA(QQ:1140457732)\n";
Sleep(100);
cout << "请注意:在程序运行中,如果您想要关闭程序,请按下 Q键;本程序连续按下的是 回车键。\n";
Sleep(2000);
int a , b;
while (true)
{
if (-32767 == GetAsyncKeyState('Q'))
{
system("taskkill -f -im 连点器.exe -t");
}
else
{
cout << "请输入您需要连点的次数(输入0退出程序):";
cin >> a;
if (a == 0) {
system("taskkill -f -im 连点器.exe -t");
}
else {
cout << "请问您想让程序按下 鼠标左键 还是 回车键?(输入数字1或2:1:左键;2:回车键;其他键退出):";
cin >> b;
if (b == 2) {
cout << "正在启动程序,请等待三秒" << endl;
Sleep(1000);
cout << "3" << endl;
Sleep(1000);
cout << "2" << endl;
Sleep(1000);
cout << "1" << endl;
for (int i = 1; i <= a; i++) {
keybd_event(VK_RETURN, 0, 0, 0);
keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
Sleep(10);
if (-32767 == GetAsyncKeyState('Q'))
{
system("taskkill -f -im 连点器.exe -t");
i = a;
}
}
}
else if (b == 1) {
cout << "正在启动程序,请等待三秒" << endl;
Sleep(1000);
cout << "3" << endl;
Sleep(1000);
cout << "2" << endl;
Sleep(1000);
cout << "1" << endl;
for (int i = 1; i <= a; i++) {
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Sleep(10);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep(10);
if (-32767 == GetAsyncKeyState('Q'))
{
system("taskkill -f -im 连点器.exe -t");
i = a;
}
}
}
else {
system("taskkill -f -im 连点器.exe -t");
}
}
}
}
}
测试过了能用。希望能对大家有帮助。