Jump to content
Sign in to follow this  

Another mouse odometer

Recommended Posts

Thanks to burrup for the idea!

HotkeySet("{ESC}", "myexit")
HotkeySet("+{ESC}", "hide")

Global $1, $2, $px, $py, $pixels
Global $hidden = 0
If FileExists("pixels.txt") Then $pixels = Int(FileReadLine("pixels.txt", 1))

While 1
  If mousemoved() Then chk()

Func chk()
  $px = 0
  $py = 0
    Case $1[0] > $2[0]
      $px = $1[0] - $2[0]
    Case $1[0] < $2[0]
      $px = $2[0] - $1[0]
    Case $1[1] > $2[1]
      $py = $1[1] - $2[1]
    Case $1[1] < $2[1]
      $py = $2[1] - $1[1]
  $pixels = $pixels + $px + $py
  $cm = $pixels / 41.5
  $me = $cm / 100
  If $hidden = 0 Then
    ToolTip(Round($me, 2) & " m")

Func mousemoved()
   $1 = MouseGetPos()
   $2 = MouseGetPos()
   If $2[0] <> $1[0] or $2[1] <> $1[1] Then 
      Return 1
      Return 0

Func hide()
  HotkeySet("+{ESC}", "unhide")
  $hidden = 1

Func unhide()
  HotkeySet("+{ESC}", "hide")
  $hidden = 0

Func myexit()

Func OnAutoItExit()
  If FileExists("pixels.txt") Then FileDelete("pixels.txt")
  FileWrite("pixels.txt", $pixels)

It records the pixels into a file to see how many meters your mouse actually went!

1 cm = 41.5 pixels

Share this post

Link to post
Share on other sites

Good job! Something i recommend is creating a GUI or something that floats in the top left corner though so it doesn't flicker so much.

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post

Link to post
Share on other sites

Pretty cool, but your pixel distance calculation is wrong, it should be

$pixels = $pixels + sqrt ($px*$px + $py*$py)

and the Select staement becomes unnecessary since $var*$var will always be positive.

I played around with showing velocity and acceleration but it wasn't nearly as interesting as I had hoped, and it changes so fast that no valuable information can be gleaned. (unless it was logged, which would be WAY to tedious to read.)

601DisengageEnd Program

Share this post

Link to post
Share on other sites

np erifash, glad to see other people can get idea and learn from it =)

and correction the Distance formula is

D = sqrt((x2-x1)² + (y2-x1)²)

in ur case

$pixels = $pixels + sqrt((($2[0] - $1[0]) * ($2[0] - $1[0])) + (($2[1] - $1[1]) * ($2[1] - $1[1])))

edit: typo


D = sqrt((x2-x1)² + (y2-y1)²)

Edited by burrup


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...