Detect mouse held

So my AutoClicker code below detects if the mouse button is pressed and simulates clicking so in a game you can hold down the mouse button and it'll click for you. The only problem is that it detects for the LBUTTON to be down and then simulates the LBUTTON being down so it doesn't stop when you let go of the mouse button. Is there a way to change VK_LBUTTON to only activate if its held for more than 1 second or something so the simulated mouse clicks don't keep it on a loop?

Thanks,
Sam

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include <iostream>
#include <cstdlib>
#include <windows.h>
using namespace std;

int main() {
while(1)
if (GetAsyncKeyState(VK_LBUTTON))
        {
        mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
        mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
        Sleep(50);
        }
cin.get();
cin.get();
return 0;
}
Why not use a different event as the trigger, such as holding down a key?
Would it be possible with the mouse button though
Topic archived. No new replies allowed.