I am currently trying to develop an auto-clicker. However, it does not seem to work. I am quite new to C++, so there may be some obvious solutions I have not tried. The following code is all in a while(1) loop:
if (GetAsyncKeyState('R')) {
click = true;
}
if (GetAsyncKeyState('F')) {
click = false;
}
if (GetAsyncKeyState(VK_DELETE)) {
abort();
}
if ((GetAsyncKeyState(VK_LBUTTON) & 0x80) != 0) {
mwdown = true;
}
else { mwdown = false; }
if (click == true) {
if (mwdown == true) {
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Sleep((rand() % 50) + 30);
if (GetAsyncKeyState('F')) {
click = false;
if (GetAsyncKeyState(VK_DELETE)) {
abort();
}
if (GetAsyncKeyState(VK_DELETE)) {
abort();
}
}
} if (GetAsyncKeyState('P')) {
if (hidden == false) {
HideConsole();
hidden = true;
Sleep(1000);
}
else {
ShowConsole();
hidden = false;
Sleep(1000);
}
}
}
I was expecting to click R and hold down the left mouse button as my mouse would have clicked. However, no clicks happen. I believe this happens as holding down the left mouse button interferes with the click.
If anyone could tell me how to make it work, I would be very grateful. Also, if there is a way to make this both activated and deactivated by pressing R, I would appreciate somebody telling me how to do it. Thanks.
I have tried a debug output. When I hold down the button, it only prints "de". However, as soon as I hit 'F' and make 'click = false', it finishes printing "debug". This only happens once.