Rapid-Fire Macro Loop Enigma (Low-Level Mouse Hook)

Posts 1–3 of 3 · Page 1 of 1
Rapid-Fire Macro Loop Enigma (Low-Level Mouse Hook)
Hello!
I am making a rapid-fire program, that autoclicks fast when the user holds the Left-mouse button down.

I usually would use GetAsyncKeyState, but since the same detects raw input, it will detect the clicks made by the program, and then continue clicking and never stop.

Example of problem:


Code:
 if (GetAsyncKeyState(VK_LBUTTON))
    {
    mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
    Sleep (10);
    }
I have searched for days, and all threads said for me to use a Low-Level MouseHook, The documentation is very confusing (especially for a beginner).

How could I make this work, could someone give me an example of a mouse hook detecting left mouse hold?

Thanks for reading!
fast means not impossible to get it noticed by the application.
a sleep between down and up should fix your problem
I don't think a low level mouse hook would change anything, you'll still run into the same loop, also, holding down LMB physically with a MOUSEEVENTF_LEFTUP means that the app no longer considers you as holding down LMB.

Your best bet is to identify what the game changes when LMB is held down, and toggle that on and off while LMB is held.

For example in source games you'd hook usercmd, and constantly toggle Cmd->buttons's IN_ATTACK flag.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?