At the moment I'm trying to add a toggle key and make it hold to click, so that when I toggle it and hold down left click, it starts clicking. Currently it boots up and when I center the CPS it clicks, but it doesn't stop. It'll click continuously.
#include <iostream>
#include <windows.h>
using namespace std;
int x = 0, y = 0, cps;
bool click = false;
void Menu()
{
cout << "Add CPS (click per second):" << endl;
cin >> cps;
}
void Clicker()
{
while (1)
{
if (GetAsyncKeyState(VK_LBUTTON))
{
click = true;
}
if (GetAsyncKeyState(VK_RBUTTON))
{
click = false;
}
if (click == true)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
Sleep(1000 / cps);
}
}
}
int main()
{
Menu();
Clicker();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…