Directions := ["sd","s","as","a","wa","w","wd","d"]
; down+right,right,up+right,up,... counterclockwise
keypress := ""
MButton::
MouseGetPos, X2, Y2
Loop
{
Sleep, 100
if !GetKeyState("MButton", "P")
{
Send, {%keypress% up}
keypress := ""
break
}
MouseGetPos, X1, Y1
k := Directions[1+(Round(3+Atan2(X2-X1,Y2-Y1)/Atan(1))&7)]
if(keypress != k)
{
Send, {%keypress% up}
keypress := k
Send, {%keypress% down}
}
}
Return
Atan2(x,y)
{
return dllcall("msvcrt\atan2","Double",y,"Double",x,"CDECL Double")
}