Autoclicker

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?
Well, it's not "random", because you are apparently asking the user to specify it.

Where do you actually call Menu()?

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
prxvvy wrote:
It's what I did to generate random numbers

There's no random-number generation there.

I ask again ... where do you actually call Menu() ... so that you get the chance to enter cps.

If you don't show runnable code it can be very difficult for others to debug it.
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;
What do you mean by "There's no random-number generation there." By the way?
@prxvvy random means nobody know what result will turn out.
there is a library to generate random results:
http://www.cplusplus.com/reference/random/
Topic archived. No new replies allowed.