Page 1 of 1

Mouse_event in a loop

Posted: 06 Apr 2018, 04:32
by THEjuozasXD
Hey,
need some help figuring out how this works, I have a mouse_event set to move the cursor in a certain direction. it's looping to create a smoothness imitation, without sleep the loop takes 0 ms to complete, but for some reason with sleep only set to 1 ms loop takes 281 ms to complete, to put this into perspective heres the code:

Code: Select all

#NoEnv
MS := A_TickCount
x = 0
loop  {
	x += 10
	DllCall("mouse_event",uint,1,int, 70 ,int, 0,uint,0,int,0)
	if (x > 180) {
		break
	}
	sleep 1
}
time := A_TickCount - MS
Msgbox % time
try it without sleep and with sleep...

Re: Mouse_event in a loop  Topic is solved

Posted: 06 Apr 2018, 11:36
by noname
Take a look at the "sleep" documentation (see the remarks),i think it contains the answer to your question.

https://autohotkey.com/docs/commands/Sleep.htm