been trying to make a basic auto clicker and cannot seem to get MouseInput to click the mouse. I believe it's probably something simple causing this issue. No errors occur it just won't do what it is intended to do.
Could somebody take a look at it and tell me whats wrong with it?
#include <iostream>
#include <Windows.h>
#include <thread>
#include <conio.h>
void loop()
{
int cps;
std::cout << "Enter desired clicks per second: ";
std::cin >> cps;
bool toggled = false;
while (true)
{
static bool bPressedToggle = false;
if (GetKeyState(VK_TAB) < 0)
bPressedToggle = true;
else if (bPressedToggle)
{
bPressedToggle = false;
toggled = !toggled;
std::cout << (toggled ? "Toggled" : "Disabled") << std::endl;
if (!toggled) continue;
}
if (toggled && (GetAsyncKeyState(VK_LBUTTON) & (1 << 16)))
{
POINT pntCurrentCursor;
GetCursorPos(&pntCurrentCursor);
INPUT inpMouseInput;
inpMouseInput.type = INPUT_MOUSE;
inpMouseInput.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
inpMouseInput.mi.dx = pntCurrentCursor.x;
inpMouseInput.mi.dy = pntCurrentCursor.y;
SendInput(1, &inpMouseInput, sizeof(INPUT)); // DOWN
RtlZeroMemory(&inpMouseInput, sizeof(INPUT));
inpMouseInput.type = INPUT_MOUSE;
inpMouseInput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
inpMouseInput.mi.dx = pntCurrentCursor.x;
inpMouseInput.mi.dy = pntCurrentCursor.y;
SendInput(1, &inpMouseInput, sizeof(INPUT)); // UP
Sleep( 1000 / cps);
}
//Sleep(1);
}
}
int main()
{
loop();
return 0;
} ```