FireFox Posted December 17, 2008 Posted December 17, 2008 (edited) Hi,I want to make mouse "travel pixel" wich calculate how long your mouse have travel pixelHere is the start : I know thats completly wrong $place = MouseGetPos() $long = $place[0] $long1 = $place[1] $lastmove = $place[0] & "|" & $place[1] While 1 Sleep(50) $Move = MouseGetPos() If $Move[0] & "|" & $Move[1] <> $lastmove Then If $Move[0] < 0 And $Move[1] < 0 Then $long = $long - $Move[0] $long1 = $long1 - $Move[1] $lastmove = $Move[0] & "|" & $Move[1] ElseIf $Move[0] > 0 And $Move[1] > 0 Then $long = $long + $Move[0] $long1 = $long1 + $Move[1] $lastmove = $Move[0] & "|" & $Move[1] ElseIf $Move[0] < 0 And $Move[1] > 0 Then $long = $long - $Move[0] $long1 = $long1 + $Move[1] $lastmove = $Move[0] & "|" & $Move[1] ElseIf $Move[0] > 0 And $Move[1] < 0 Then $long = $long + $Move[0] $long1 = $long1 - $Move[1] $lastmove = $Move[0] & "|" & $Move[1] EndIf EndIf TrayTip("Mouse pixel travel", $long + $long1 & " pixel", 2, 4) WEndThat's I don't arrive to do I to calculate mouse pos before + mouse pos after and of course in diagonalHere is an example :And it seems to be the theoreme of pythagore for calculate mouse pos after of mouse pos before...If i find solution I will post scriptThanks for anyhelp Edited December 17, 2008 by FireFox
weaponx Posted December 17, 2008 Posted December 17, 2008 Distance between point P (Point 1) and Q (Point 2)... Sqrt(($X2 -$X1)^2 + ($Y2 - $Y1)^2)
FireFox Posted December 17, 2008 Author Posted December 17, 2008 Distance between point P (Point 1) and Q (Point 2)... Sqrt(($X2 -$X1)^2 + ($Y2 - $Y1)^2) Thanks for your reply, i understand what its for but i dont arrive to make it work with my noob script : (and again completly wrong) Local $last,$lastx,$lasty While 1 $Move=MouseGetPos() $square = Sqrt(($lastx + $lasty) ^ 2 + ($move[0] + $move[1]) ^ 2) $total = $last+$square $last = $square $lastx = $Move[0] $lasty = $Move[1] TrayTip("Mouse pixel travel", $total & " pixel", 2, 4) WEnd What I think is get last pos + square but dont work... Thanks for your help
SaphuA Posted December 17, 2008 Posted December 17, 2008 Thanks for your reply, i understand what its for but i dont arrive to make it work with my noob script : (and again completly wrong) Local $last,$lastx,$lasty While 1 $Move=MouseGetPos() $square = Sqrt(($lastx + $lasty) ^ 2 + ($move[0] + $move[1]) ^ 2) $total = $last+$square $last = $square $lastx = $Move[0] $lasty = $Move[1] TrayTip("Mouse pixel travel", $total & " pixel", 2, 4) WEnd What I think is get last pos + square but dont work... Thanks for your help You're doing the Sqrt wrong, look at the code above and at what you're doing. Besides that; the result of the Sqrt is already the distance so there's no need to add $last to that result. http://www.saphua.com/
weaponx Posted December 17, 2008 Posted December 17, 2008 Dim $last_pos[2] = [0,0] While 1 $current_pos = MouseGetPos() $distance = Sqrt(($current_pos[0] - $last_pos[0]) ^ 2 + ($current_pos[1] - $last_pos[1]) ^ 2) $last_pos = $current_pos TrayTip("Mouse pixel travel", $distance & " pixels", 2, 4) Sleep(500) WEnd
FireFox Posted December 17, 2008 Author Posted December 17, 2008 Dim $last_pos[2] = [0,0] While 1 $current_pos = MouseGetPos() $distance = Sqrt(($current_pos[0] - $last_pos[0]) ^ 2 + ($current_pos[1] - $last_pos[1]) ^ 2) $last_pos = $current_pos TrayTip("Mouse pixel travel", $distance & " pixels", 2, 4) Sleep(500) WEnd Thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I've little change it for have total distance of the mouse Dim $last_pos[2] = [0, 0] Dim $lastdistance While 1 $current_pos = MouseGetPos() $distance = Sqrt(($current_pos[0] - $last_pos[0]) ^ 2 + ($current_pos[1] - $last_pos[1]) ^ 2) $total = $distance + $lastdistance $lastdistance = $total $last_pos = $current_pos TrayTip("Mouse pixel travel", $total & " pixels", 2, 4) Sleep(50) WEnd
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now