K
K
Kvert0072014-09-18 13:57:31
C++ / C#
Kvert007, 2014-09-18 13:57:31

How to implement mouse click every 5 sec (C++)?

I'm writing something like an autoclicker.
There is an endless loop

while (1)
  {
          SendMessage(hPointWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(540,360));
           SendMessage(hPointWnd, WM_LBUTTONUP, 0, MAKELONG(540,360));
       }

You need to do the following:
1) Start the cycle and stop by pressing the f12 key.
2) Implement a delay between clicks of 5 seconds
Tell me how to do this please?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Kyberman, 2014-09-18
@Kyberman

If the application is windowed, then it is better to use a timer. Then you can avoid hanging from sleep, and multithreading is not needed.
F12 toggle the flag and, depending on its value, call either SetTimer or KillTimer .
If the application is without a GUI, then @GavriKos solution will do .

G
GavriKos, 2014-09-18
@GavriKos

Delay - sleep(5000) or something like that.
On f12 - toggle the flag (flag=!flag) in which thread the handler of the pressed key, in the cycle, respectively, the condition - if the flag is set - poke the mouse.

A
AxisPod, 2014-09-18
@AxisPod

msdn.microsoft.com/en-us/library/windows/desktop/m...

K
Kvert007, 2014-09-18
@Kvert007

Console app =(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question