,y`k'd2VFGcs-"yVYX;:Mcl+W/QS(x5Oc!=d%r.R-[jD:;'Ee)$?4lkj?.x|qTDk&_ekd'#)q@a>.XaNQO;m$2WiHvI6f$o(VSp3SQ={ous"1SUPC"Ke1e-` Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: mouse move script help ?

Post by Ianizer » 19 Sep 2021, 09:50

Just read the comment on line 12:

Code: Select all

#MaxThreadsPerHotkey 2
SetBatchLines, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
DllCall("QueryPerformanceFrequency", "Int64*", QPCFrequency)

F4::
	MoveMouse := !MoveMouse
	while (MoveMouse)
	{
		MouseMove, 1, 0,, R
		AccuSleepBreakable(15, MoveMouse) ;lower the 15 to move the mouse faster. the time is in milliseconds
	}
return

AccuSleepBreakable(TimeToSleep := 10, ByRef VarThatStopsTheSleepLoopIfTrue := 0, ByRef VarThatStopsTheSleepLoopIfTrue2 := 0, ByRef VarThatStopsTheSleepLoopIfValueChanges := 0)
{ ;time to Sleep in ms ;returns amount of time slept in ms ;Accuracy: ~2ms ;I recomended to sleep for 0.4ms less than you want since it stops sleeping when elapsed time >= TimeToSleep
	DllCall("QueryPerformanceCounter", "Int64*", StartTime)
	OldVarValue := VarThatStopsTheSleepLoopIfValueChanges
	global QPCFrequency
	TimeToSleep := (TimeToSleep/1000)*QPCFrequency
	Loop
	{
		DllCall("Winmm\timeBeginPeriod", "UInt", 1)
		DllCall("Sleep", "UInt", 1)
		DllCall("Winmm\timeEndPeriod", "UInt", 1)
		DllCall("QueryPerformanceCounter", "Int64*", CurrentTime)
	}until ((CurrentTime - StartTime >= TimeToSleep) || (VarThatStopsTheSleepLoopIfTrue || VarThatStopsTheSleepLoopIfTrue2 || VarThatStopsTheSleepLoopIfValueChanges != OldVarValue))
	return ((CurrentTime - StartTime)/QPCFrequency)*1000
}

Ianizer
Posts: 79
Joined: 07 Mar 2021, 00:06

Re: mouse move script help ?

Post by Ianizer » 19 Sep 2021, 14:33

My bad, I forgot some commas:

Code: Select all

#MaxThreadsPerHotkey 2
SetBatchLines, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
DllCall("QueryPerformanceFrequency", "Int64*", QPCFrequency)

F4::
	MoveMouse := !MoveMouse
	while (MoveMouse)
	{
		MouseMove, 1, 0,, R
		AccuSleepBreakable(15,,, MoveMouse) ;lower the 15 to move the mouse faster. the time is in milliseconds
	}
return

AccuSleepBreakable(TimeToSleep := 1, ByRef VarThatStopsTheSleepLoopIfTrue := 0, ByRef VarThatStopsTheSleepLoopIfTrue2 := 0, ByRef VarThatStopsTheSleepLoopIfValueChanges := 0)
{ ;time to Sleep in ms ;returns amount of time slept in ms ;Accuracy: ~2ms ;I recomended to sleep for 0.4ms less than you want since it stops sleeping when elapsed time >= TimeToSleep
	DllCall("QueryPerformanceCounter", "Int64*", StartTime)
	OldVarValue := VarThatStopsTheSleepLoopIfValueChanges
	global QPCFrequency
	TimeToSleep := (TimeToSleep/1000)*QPCFrequency
	Loop
	{
		DllCall("Winmm\timeBeginPeriod", "UInt", 1)
		DllCall("Sleep", "UInt", 1)
		DllCall("Winmm\timeEndPeriod", "UInt", 1)
		DllCall("QueryPerformanceCounter", "Int64*", CurrentTime)
	}until ((CurrentTime - StartTime >= TimeToSleep) || (VarThatStopsTheSleepLoopIfTrue || VarThatStopsTheSleepLoopIfTrue2 || VarThatStopsTheSleepLoopIfValueChanges != OldVarValue))
	return ((CurrentTime - StartTime)/QPCFrequency)*1000
}

Rohwedder
Posts: 7549
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: mouse move script help ?  Topic is solved

Post by Rohwedder » 20 Sep 2021, 00:13

Hallo,
try:

Code: Select all

SetMouseDelay, -1,% Speed := 10
F4::SetTimer, F4 Up,% (F4:=!F4*Speed)?15:"Off"
F4 Up::MouseMove, F4, 0, 0, R

Post Reply

Return to “Gaming Help (v1)”