Oct 15, 2019 at 3:34pm UTC
Hello, I've recently started to learn C++ and was trying to code an autoclicker. This one's a simple one but I'd like to it to generate random clicks for instance, between 12-20 clicks per second, I tried to use random library. However it only does 10-12 clicks per second.
This one is the code I've been using
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
int x=0, y=0;
int cps = 14;
bool click=false;
bool KeyDown(int vk)
{
if (GetKeyState(vk) & 0x8000)
return true;
return false;
}
bool KeyUp(int vk)
{
if (GetKeyState(vk) == 0)
return true;
return false;
}
void Clicker()
{
while (!KeyDown(VK_F4))
{
if (KeyDown(VK_LBUTTON))
{
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
Sleep(1000/cps);
if(KeyUp(VK_LBUTTON))
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
}
}
int main()
{
FreeConsole();
Clicker();
Sleep(10);
}
and this one's when I've been trying to generate random clicks per second
int x = 0, y = 0, cps;
bool click = false;
void Menu()
{
float cps_min = 16;
float cps_max = 22;
float cps_min_ms;
float cps_max_ms;
cps_min_ms = ((1 / cps_min) * 1000);
cps_max_ms = ((1 / cps_max) * 1000);
cin >> cps;
}
Could someone help me to generate random clicks per second or at least tell me what I'm doing wrong?
Oct 15, 2019 at 4:16pm UTC
Well, it's not "random", because you are apparently asking the user to specify it.
Where do you actually call Menu()
?
Oct 15, 2019 at 4:54pm UTC
That's just a little part of my code
float cps_min = 16;
float cps_max = 22;
float cps_min_ms;
float cps_max_ms;
cps_min_ms = ((1 / cps_min) * 1000);
cps_max_ms = ((1 / cps_max) * 1000);
cin >> cps;
It's what I did to generate random numbers and then used cin to put the numbers in int cps
Last edited on Oct 15, 2019 at 4:56pm UTC
Oct 15, 2019 at 5:15pm UTC
Ok sorry for misunderstanding, menu is not actually part of my code but what it's inside of it it's part of what I'm doing to generate random numbers it something like this
int x=0, y=0, cps;
bool click=false;
float cps_min = 16;
float cps_max = 22;
float cps_min_ms;
float cps_max_ms;
cps_min_ms = ((1 / cps_min) * 1000);
cps_max_ms = ((1 / cps_max) * 1000);
cin >> cps;
Oct 15, 2019 at 5:19pm UTC
What do you mean by "There's no random-number generation there." By the way?