Zugbug

Autohotkey for left+right mbtn scrolling

Sep 14th, 2014
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Author  : Zugbug
  2. ;version : 0.9.6
  3. ;licence : do-whatever-you-wanna-do
  4. ;
  5. ;This autohotkey script is designed to
  6. ;make mice without a scroll wheel easier
  7. ;to use. When finished, it will allow you
  8. ;to use left & right mouse buttons as
  9. ;a scrolling feature, something that you'd
  10. ;see on a laptop where you can tap both
  11. ;buttons for a middle button click, or
  12. ;hold them and move the mouse to scroll.
  13. ;This script was inspired by the fact
  14. ;that my Trackman Marble worked better
  15. ;on Linux rather than Windows and that
  16. ;I couldn't find one other single solution
  17. ;to do this for me.
  18. ;
  19. ;I wanna finish by adding a few keywords so
  20. ;that some other poor sod doesn't have to
  21. ;scour the internet like I had to.
  22. ;
  23. ;keywords : Trackman, Marble, scroll, buttons,
  24. ;script, two, left+right, middle, autoscroll,
  25. ;laptop like, hold to scroll, feel free to
  26. ;share and add
  27. ;
  28.  
  29.  
  30. CoordMode, Mouse, Screen
  31. #Persistent
  32. #SingleInstance force
  33.  
  34.  
  35.  
  36. ; TODO Detect the longevity of the keystroke to determine whether to send
  37. ; TODO a MButton or to go into the Update Subroutine
  38. ; TODO Also, put back in the part which monitored the amount of movement
  39. ; TODO in the form of change from X to MovedX
  40. RButton & LButton::
  41. SetTimer, Update, 10
  42. MouseGetPos, origX, origY
  43. MouseGetPos, X, Y
  44.  
  45. While (GetKeyState("LButton","P") && GetKeyState("RButton","P"))
  46.     {
  47.        
  48.         MState := True
  49.         Sleep, 10
  50.     }
  51. MState := False
  52.  
  53. return
  54.  
  55. RButton::Send {RButton}
  56.  
  57. ; TODO
  58.  
  59. Update:
  60.  
  61. MouseGetPos, X, Y
  62. ;SetTimer, waitForMove, 25
  63. If (OldX <> X || OldY <> Y)
  64. {
  65.     MovedX := ((OldX - X) > 0) ? (OldX - X) : -(OldX - X)
  66. ;   msgbox, %MovedX%
  67.     MovedY := ((OldY - Y) > 0) ? (OldY - Y) : -(OldY - Y)
  68. ;   msgbox, %MovedY%
  69.     If (OldX < X) && (MovedX > MovedY) && (MovedX > 1)
  70.         Direction = Side
  71.     If (OldX > X) && (MovedX > MovedY) && (MovedX > 1)
  72.         Direction = Side
  73.     If (OldY < Y) && (MovedX < MovedY) && (MovedY > 1)
  74.         Direction = South
  75.     If (OldY > Y) && (MovedX < MovedY) && (MovedY > 1)
  76.         Direction = North
  77.     If ((GetKeyState("LButton","P") && GetKeyState("RButton","P")) && Direction)
  78.         GoSub, %Direction%
  79.  
  80. }
  81.  
  82. MouseGetPos, OldX, OldY
  83. Return
  84.  
  85. waitForMove:
  86. msgbox, test
  87. return
  88. ;TODO Set up the function to move the mouse back to the original coords. Try
  89. ;TODO MouseMove on line 38ish
  90.  
  91. South:
  92. Sleep, 1
  93. MouseMove, origX, origY+5
  94. Send {WheelDown}
  95. return
  96.  
  97. North:
  98. Sleep, 1
  99. MouseMove, origX, origY-5
  100. Send {WheelUp}
  101. return
  102.  
  103. Side:
  104. Sleep, 1
  105. MouseMove, origX, origY
  106. return
Advertisement
Add Comment
Please, Sign In to add comment