Sign in to follow this  
Followers 0
FireFox

How to make mouse "travel pixel"

6 posts in this topic

#1 ·  Posted (edited)

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites



Distance between point P (Point 1) and Q (Point 2)...

Sqrt(($X2 -$X1)^2 + ($Y2 - $Y1)^2)

Share this post


Link to post
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 :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0