Advertisement
Guest User

scroll

a guest
Jun 24th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. ; Accelerated Scrolling
  2.  
  3. #NoEnv
  4. #NoTrayIcon
  5. #SingleInstance
  6. #MaxHotkeysPerInterval 120
  7.  
  8. Process, Priority, , H
  9. SendMode Input
  10.  
  11. ; Show scroll velocity as a tooltip while scrolling. 1 or 0.
  12. tooltips := 0
  13.  
  14. ; The length of a scrolling session.
  15. ; Keep scrolling within this time to accumulate boost.
  16. ; Default: 500. Recommended between 400 and 1000.
  17. timeout := 500
  18.  
  19. ; If you scroll a long distance in one session, apply additional boost factor.
  20. ; The higher the value, the longer it takes to activate, and the slower it accumulates.
  21. ; Set to zero to disable completely. Default: 30.
  22. boost := 30
  23.  
  24. ; Spamming applications with hundreds of individual scroll events can slow them down.
  25. ; This sets the maximum number of scrolls sent per click, i.e. max velocity. Default: 60.
  26. limit := 60
  27.  
  28. ; Runtime variables. Do not modify.
  29. distance := 0
  30. vmax := 1
  31.  
  32. ; Key bindings
  33. WheelUp:: Goto Scroll
  34. WheelDown:: Goto Scroll
  35. #WheelUp:: Suspend
  36. #WheelDown:: Goto Quit
  37.  
  38. Scroll:
  39. t := A_TimeSincePriorHotkey
  40. if (A_PriorHotkey = A_ThisHotkey && t < timeout)
  41. {
  42. ; Remember how many times we've scrolled in the current direction
  43. distance++
  44.  
  45. ; Calculate acceleration factor using a 1/x curve
  46. v := (t < 80 && t > 1) ? (250.0 / t) - 1 : 1
  47.  
  48. ; Apply boost
  49. if (boost > 1 && distance > boost)
  50. {
  51. ; Hold onto the highest speed we've achieved during this boost
  52. if (v > vmax)
  53. vmax := v
  54. else
  55. v := vmax
  56.  
  57. v *= distance / boost
  58. }
  59.  
  60. ; Validate
  61. v := (v > 1) ? ((v > limit) ? limit : Floor(v)) : 1
  62.  
  63. if (v > 1 && tooltips)
  64. QuickToolTip("×"v, timeout)
  65.  
  66. MouseClick, %A_ThisHotkey%, , , v
  67. }
  68. else
  69. {
  70. ; Combo broken, so reset session variables
  71. distance := 0
  72. vmax := 1
  73.  
  74. MouseClick %A_ThisHotkey%
  75. }
  76. return
  77.  
  78. Quit:
  79. QuickToolTip("Exiting Accelerated Scrolling...", 1000)
  80. Sleep 1000
  81. ExitApp
  82.  
  83. QuickToolTip(text, delay)
  84. {
  85. ToolTip, %text%
  86. SetTimer ToolTipOff, %delay%
  87. return
  88.  
  89. ToolTipOff:
  90. SetTimer ToolTipOff, Off
  91. ToolTip
  92. return
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement