Advertisement
Guest User

LastClick.ahk

a guest
Jan 24th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* INSTRUCTIONS
  2. *
  3. * 1. Copy and paste this into notepad.
  4. * 2. Save the file as "LastClick.ahk" (name doesn't matter, extension does).
  5. * 3. If you have AHK installed, you should be able to double click the file to run it.
  6. *
  7. * Once the script is running, each time you click with the left mouse button
  8. * a Tray Tip will appear above the AHK icon on your toolbar, displaying the
  9. * time since you last clicked (Format is "minutes:seconds").
  10. *
  11. * To pause the script (prevent tooltip from displaying), right click on the AHK icon on
  12. * you toolbar and click "Suspend Hotkeys".
  13. * To close the scropt, right click on the AHK icon and click "Exit".
  14. */
  15.  
  16. #CommentFlag, //
  17.  
  18. lastTick := 0
  19.  
  20. // Set hotkey as the Left mouse Button
  21. // The '~' ensures the native function of the key (clicking)
  22. // won't be blocked.
  23. ~LButton::
  24.  
  25. // Find difference since last tick
  26. currentTick := A_TickCount
  27. t := currentTick - lastTick
  28.  
  29. // First time used, so t is 0
  30. if (lastTick = 0)
  31. {
  32.     t := 0
  33. }
  34. // Set last tick to this tick
  35. lastTick := currentTick
  36.  
  37. // Convert ms to seconds
  38. tsec := Floor(t / 1000)
  39. tmin := 0
  40.  
  41. if (tsec >= 60)
  42. {
  43.     // Get how many minutes it's been
  44.     tmin := Floor(tsec / 60)
  45.     tsec := Mod(tsec , 60)
  46. }
  47.  
  48. // Display a traytip displaying the time
  49. title := "Time since last click"
  50. msg := tmin . ":" . tsec
  51. TrayTip, %title%, %msg%, 5, 17
  52. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement