Jump to content

How to make mouse "travel pixel"


FireFox
 Share

Recommended Posts

Hi,

I want to make mouse "travel pixel" wich calculate how long your mouse have travel pixel

Here 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)
 WEnd

That's I don't arrive to do I to calculate mouse pos before + mouse pos after and of course in diagonal

Here is an example :

Posted Image

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 script

Thanks for anyhelp :)

Edited by FireFox
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...