Mouse_event in a loop

Get help with using AutoHotkey and its commands and hotkeys
THEjuozasXD

Mouse_event in a loop

06 Apr 2018, 04:32

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...
User avatar
noname
Posts: 509
Joined: 19 Nov 2013, 09:15

Re: Mouse_event in a loop

06 Apr 2018, 11:36

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
soundcloud.com/user-32706894

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], TheMainEvent and 70 guests