I also tried to use Sleep because I saw in someone's code which was similar to mine but now it doesn't detect clicks I want it to detect first I tested using the space key in my keyboard I thought it was only for space but when I tested using a character and mouse button I had the same issue so now I'm here to get help here's my code:
void waitforspace()
{
bool strtd = false, stop = true, set = false;
std::chrono::steady_clock::time_point nw, thn;
std::thread t1;
while (true)
{
if ((GetKeyState(VK_RBUTTON) & 0x8000))
{
// I tried this to fix the repeating issue it worked but now most of the time my clicks doesn't get detected
if (!(GetKeyState(VK_RBUTTON) & 0x8000))
{
if (set)
{
nw = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> time_span = nw - thn;
set = false;
if (time_span.count() < 350.0)
{
std::cout << "Double click Detected!\n";
if (!strtd)
{
// Function I want to run if user clicked twice
t1 = std::thread(sendclicks, &stop);
strtd = true;
}
else
{
stop = false;
strtd = false;
}
}
}
else
{
std::cout << "One click Detected!\n";
thn = std::chrono::high_resolution_clock::now();
set = true;
}
}
}
}
}