Saturday, December 27, 2008

AHK - Random Mouse Path (MouseMove)

This functions chooses random points along the path from the current mouse position to the new one, and moves through those points on the way to the new position. This function is supposed to help prevent people from detecting the use of a bot based on movement patterns. The first two parameters are the X and Y coordinates respectively, and the third (optional) parameter is the speed at which the mouse will move. For more information on this parameter see here. The default is 25.
MoveMouse(X, Y, Speed=25) {
T := A_MouseDelay
SetMouseDelay, -1
MouseGetPos, CX, CY
Pts := Round(Sqrt((X - CX)**2 + (Y - CY)**2) / 30,0)
Loop %Pts% {
Random, NX, % CX - ((CX - X) / Pts) * (A_Index - 1)
, % CX - ((CX - X) / Pts) * A_Index
Random, NY, % CY - ((CY - Y) / Pts) * (A_Index - 1)
, % CY - ((CY - Y) / Pts) * A_Index
MouseMove, % NX, % NY, % Speed
}
MouseMove, % X, % Y, % Speed
SetMouseDelay, % T
}


Forum Post

No comments: