Guest User

NumPadAsKeyboard

a guest
Jul 25th, 2013
876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. o------------------------------------------------------------o
  3. |Using Keyboard Numpad as a Mouse                            |
  4. (------------------------------------------------------------)
  5. | By deguix           / A Script file for AutoHotkey 1.0.22+ |
  6. |                    ----------------------------------------|
  7. |                                                            |
  8. |    This script is an example of use of AutoHotkey. It uses |
  9. | the remapping of numpad keys of a keyboard to transform it |
  10. | into a mouse. Some features are the acceleration which     |
  11. | enables you to increase the mouse movement when holding    |
  12. | a key for a long time, and the rotation which makes the    |
  13. | numpad mouse to "turn". I.e. NumPadDown as NumPadUp        |
  14. | and vice-versa. See the list of keys used below:           |
  15. |                                                            |
  16. |------------------------------------------------------------|
  17. | Keys                  | Description                        |
  18. |------------------------------------------------------------|
  19. | ScrollLock (toggle on)| Activates numpad mouse mode.       |
  20. |-----------------------|------------------------------------|
  21. | NumPad0               | Left mouse button click.           |
  22. | NumPad5               | Middle mouse button click.         |
  23. | NumPadDot             | Right mouse button click.          |
  24. | NumPadDiv/NumPadMult  | X1/X2 mouse button click. (Win 2k+)|
  25. | NumPadSub/NumPadAdd   | Moves up/down the mouse wheel.     |
  26. |                       |                                    |
  27. |-----------------------|------------------------------------|
  28. | NumLock (toggled off) | Activates mouse movement mode.     |
  29. |-----------------------|------------------------------------|
  30. | NumPadEnd/Down/PgDn/  | Mouse movement.                    |
  31. | /Left/Right/Home/Up/  |                                    |
  32. | /PgUp                 |                                    |
  33. |                       |                                    |
  34. |-----------------------|------------------------------------|
  35. | NumLock (toggled on)  | Activates mouse speed adj. mode.   |
  36. |-----------------------|------------------------------------|
  37. | NumPad7/NumPad1       | Inc./dec. acceleration per         |
  38. |                       | button press.                      |
  39. | NumPad8/NumPad2       | Inc./dec. initial speed per        |
  40. |                       | button press.                      |
  41. | NumPad9/NumPad3       | Inc./dec. maximum speed per        |
  42. |                       | button press.                      |
  43. | ^NumPad7/^NumPad1     | Inc./dec. wheel acceleration per   |
  44. |                       | button press*.                     |
  45. | ^NumPad8/^NumPad2     | Inc./dec. wheel initial speed per  |
  46. |                       | button press*.                     |
  47. | ^NumPad9/^NumPad3     | Inc./dec. wheel maximum speed per  |
  48. |                       | button press*.                     |
  49. | NumPad4/NumPad6       | Inc./dec. rotation angle to        |
  50. |                       | right in degrees. (i.e. 180° =     |
  51. |                       | = inversed controls).              |
  52. |------------------------------------------------------------|
  53. | * = These options are affected by the mouse wheel speed    |
  54. | adjusted on Control Panel. If you don't have a mouse with  |
  55. | wheel, the default is 3 +/- lines per option button press. |
  56. o------------------------------------------------------------o
  57. */
  58.  
  59. ;START OF CONFIG SECTION
  60.  
  61. #SingleInstance force
  62. #MaxHotkeysPerInterval 500
  63.  
  64. ; Using the keyboard hook to implement the Numpad hotkeys prevents
  65. ; them from interfering with the generation of ANSI characters such
  66. ; as à.  This is because AutoHotkey generates such characters
  67. ; by holding down ALT and sending a series of Numpad keystrokes.
  68. ; Hook hotkeys are smart enough to ignore such keystrokes.
  69. #UseHook
  70.  
  71. MouseSpeed = 1
  72. MouseAccelerationSpeed = 30
  73. MouseMaxSpeed = 80
  74.  
  75. ;Mouse wheel speed is also set on Control Panel. As that
  76. ;will affect the normal mouse behavior, the real speed of
  77. ;these three below are times the normal mouse wheel speed.
  78. MouseWheelSpeed = 1
  79. MouseWheelAccelerationSpeed = 1
  80. MouseWheelMaxSpeed = 5
  81.  
  82. MouseRotationAngle = 0
  83.  
  84. ;END OF CONFIG SECTION
  85.  
  86. ;This is needed or key presses would faulty send their natural
  87. ;actions. Like NumPadDiv would send sometimes "/" to the
  88. ;screen.      
  89. #InstallKeybdHook
  90.  
  91. Temp = 0
  92. Temp2 = 0
  93.  
  94. MouseRotationAnglePart = %MouseRotationAngle%
  95. ;Divide by 45º because MouseMove only supports whole numbers,
  96. ;and changing the mouse rotation to a number lesser than 45º
  97. ;could make strange movements.
  98. ;
  99. ;For example: 22.5º when pressing NumPadUp:
  100. ;  First it would move upwards until the speed
  101. ;  to the side reaches 1.
  102. MouseRotationAnglePart /= 45
  103.  
  104. MouseCurrentAccelerationSpeed = 0
  105. MouseCurrentSpeed = %MouseSpeed%
  106.  
  107. MouseWheelCurrentAccelerationSpeed = 0
  108. MouseWheelCurrentSpeed = %MouseSpeed%
  109.  
  110. SetKeyDelay, -1
  111. SetMouseDelay, -1
  112.  
  113. Hotkey, *NumPad0, ButtonLeftClick
  114. Hotkey, *NumpadIns, ButtonLeftClickIns
  115. Hotkey, *NumPad5, ButtonMiddleClick
  116. Hotkey, *NumpadClear, ButtonMiddleClickClear
  117. Hotkey, *NumPadDot, ButtonRightClick
  118. Hotkey, *NumPadDel, ButtonRightClickDel
  119. Hotkey, *NumPadDiv, ButtonX1Click
  120. Hotkey, *NumPadMult, ButtonX2Click
  121.  
  122. Hotkey, *NumpadSub, ButtonWheelUp
  123. Hotkey, *NumpadAdd, ButtonWheelDown
  124.  
  125. Hotkey, *NumPadUp, ButtonUp
  126. Hotkey, *NumPadDown, ButtonDown
  127. Hotkey, *NumPadLeft, ButtonLeft
  128. Hotkey, *NumPadRight, ButtonRight
  129. Hotkey, *NumPadHome, ButtonUpLeft
  130. Hotkey, *NumPadEnd, ButtonUpRight
  131. Hotkey, *NumPadPgUp, ButtonDownLeft
  132. Hotkey, *NumPadPgDn, ButtonDownRight
  133.  
  134. Hotkey, Numpad8, ButtonSpeedUp
  135. Hotkey, Numpad2, ButtonSpeedDown
  136. Hotkey, Numpad7, ButtonAccelerationSpeedUp
  137. Hotkey, Numpad1, ButtonAccelerationSpeedDown
  138. Hotkey, Numpad9, ButtonMaxSpeedUp
  139. Hotkey, Numpad3, ButtonMaxSpeedDown
  140.  
  141. Hotkey, Numpad6, ButtonRotationAngleUp
  142. Hotkey, Numpad4, ButtonRotationAngleDown
  143.  
  144. Hotkey, !Numpad8, ButtonWheelSpeedUp
  145. Hotkey, !Numpad2, ButtonWheelSpeedDown
  146. Hotkey, !Numpad7, ButtonWheelAccelerationSpeedUp
  147. Hotkey, !Numpad1, ButtonWheelAccelerationSpeedDown
  148. Hotkey, !Numpad9, ButtonWheelMaxSpeedUp
  149. Hotkey, !Numpad3, ButtonWheelMaxSpeedDown
  150.  
  151. Gosub, ~ScrollLock  ; Initialize based on current ScrollLock state.
  152. return
  153.  
  154. ;Key activation support
  155.  
  156. ~ScrollLock::
  157. ; Wait for it to be released because otherwise the hook state gets reset
  158. ; while the key is down, which causes the up-event to get suppressed,
  159. ; which in turn prevents toggling of the ScrollLock state/light:
  160. KeyWait, ScrollLock
  161. GetKeyState, ScrollLockState, ScrollLock, T
  162. If ScrollLockState = D
  163. {
  164.     Hotkey, *NumPad0, on
  165.     Hotkey, *NumpadIns, on
  166.     Hotkey, *NumPad5, on
  167.     Hotkey, *NumPadDot, on
  168.     Hotkey, *NumPadDel, on
  169.     Hotkey, *NumPadDiv, on
  170.     Hotkey, *NumPadMult, on
  171.  
  172.     Hotkey, *NumpadSub, on
  173.     Hotkey, *NumpadAdd, on
  174.  
  175.     Hotkey, *NumPadUp, on
  176.     Hotkey, *NumPadDown, on
  177.     Hotkey, *NumPadLeft, on
  178.     Hotkey, *NumPadRight, on
  179.     Hotkey, *NumPadHome, on
  180.     Hotkey, *NumPadEnd, on
  181.     Hotkey, *NumPadPgUp, on
  182.     Hotkey, *NumPadPgDn, on
  183.  
  184.     Hotkey, Numpad8, on
  185.     Hotkey, Numpad2, on
  186.     Hotkey, Numpad7, on
  187.     Hotkey, Numpad1, on
  188.     Hotkey, Numpad9, on
  189.     Hotkey, Numpad3, on
  190.  
  191.     Hotkey, Numpad6, on
  192.     Hotkey, Numpad4, on
  193.  
  194.     Hotkey, !Numpad8, on
  195.     Hotkey, !Numpad2, on
  196.     Hotkey, !Numpad7, on
  197.     Hotkey, !Numpad1, on
  198.     Hotkey, !Numpad9, on
  199.     Hotkey, !Numpad3, on
  200. }
  201. else
  202. {
  203.     Hotkey, *NumPad0, off
  204.     Hotkey, *NumpadIns, off
  205.     Hotkey, *NumPad5, off
  206.     Hotkey, *NumPadDot, off
  207.     Hotkey, *NumPadDel, off
  208.     Hotkey, *NumPadDiv, off
  209.     Hotkey, *NumPadMult, off
  210.  
  211.     Hotkey, *NumpadSub, off
  212.     Hotkey, *NumpadAdd, off
  213.  
  214.     Hotkey, *NumPadUp, off
  215.     Hotkey, *NumPadDown, off
  216.     Hotkey, *NumPadLeft, off
  217.     Hotkey, *NumPadRight, off
  218.     Hotkey, *NumPadHome, off
  219.     Hotkey, *NumPadEnd, off
  220.     Hotkey, *NumPadPgUp, off
  221.     Hotkey, *NumPadPgDn, off
  222.  
  223.     Hotkey, Numpad8, off
  224.     Hotkey, Numpad2, off
  225.     Hotkey, Numpad7, off
  226.     Hotkey, Numpad1, off
  227.     Hotkey, Numpad9, off
  228.     Hotkey, Numpad3, off
  229.  
  230.     Hotkey, Numpad6, off
  231.     Hotkey, Numpad4, off
  232.  
  233.     Hotkey, !Numpad8, off
  234.     Hotkey, !Numpad2, off
  235.     Hotkey, !Numpad7, off
  236.     Hotkey, !Numpad1, off
  237.     Hotkey, !Numpad9, off
  238.     Hotkey, !Numpad3, off
  239. }
  240. return
  241.  
  242. ;Mouse click support
  243.  
  244. ButtonLeftClick:
  245. GetKeyState, already_down_state, LButton
  246. If already_down_state = D
  247.     return
  248. Button2 = NumPad0
  249. ButtonClick = Left
  250. Goto ButtonClickStart
  251. ButtonLeftClickIns:
  252. GetKeyState, already_down_state, LButton
  253. If already_down_state = D
  254.     return
  255. Button2 = NumPadIns
  256. ButtonClick = Left
  257. Goto ButtonClickStart
  258.  
  259. ButtonMiddleClick:
  260. GetKeyState, already_down_state, MButton
  261. If already_down_state = D
  262.     return
  263. Button2 = NumPad5
  264. ButtonClick = Middle
  265. Goto ButtonClickStart
  266. ButtonMiddleClickClear:
  267. GetKeyState, already_down_state, MButton
  268. If already_down_state = D
  269.     return
  270. Button2 = NumPadClear
  271. ButtonClick = Middle
  272. Goto ButtonClickStart
  273.  
  274. ButtonRightClick:
  275. GetKeyState, already_down_state, RButton
  276. If already_down_state = D
  277.     return
  278. Button2 = NumPadDot
  279. ButtonClick = Right
  280. Goto ButtonClickStart
  281. ButtonRightClickDel:
  282. GetKeyState, already_down_state, RButton
  283. If already_down_state = D
  284.     return
  285. Button2 = NumPadDel
  286. ButtonClick = Right
  287. Goto ButtonClickStart
  288.  
  289. ButtonX1Click:
  290. GetKeyState, already_down_state, XButton1
  291. If already_down_state = D
  292.     return
  293. Button2 = NumPadDiv
  294. ButtonClick = X1
  295. Goto ButtonClickStart
  296.  
  297. ButtonX2Click:
  298. GetKeyState, already_down_state, XButton2
  299. If already_down_state = D
  300.     return
  301. Button2 = NumPadMult
  302. ButtonClick = X2
  303. Goto ButtonClickStart
  304.  
  305. ButtonClickStart:
  306. MouseClick, %ButtonClick%,,, 1, 0, D
  307. SetTimer, ButtonClickEnd, 10
  308. return
  309.  
  310. ButtonClickEnd:
  311. GetKeyState, kclickstate, %Button2%, P
  312. if kclickstate = D
  313.     return
  314.  
  315. SetTimer, ButtonClickEnd, off
  316. MouseClick, %ButtonClick%,,, 1, 0, U
  317. return
  318.  
  319. ;Mouse movement support
  320.  
  321. ButtonSpeedUp:
  322. MouseSpeed++
  323. ToolTip, Mouse speed: %MouseSpeed% pixels
  324. SetTimer, RemoveToolTip, 1000
  325. return
  326. ButtonSpeedDown:
  327. If MouseSpeed > 1
  328.     MouseSpeed--
  329. If MouseSpeed = 1
  330.     ToolTip, Mouse speed: %MouseSpeed% pixel
  331. else
  332.     ToolTip, Mouse speed: %MouseSpeed% pixels
  333. SetTimer, RemoveToolTip, 1000
  334. return
  335. ButtonAccelerationSpeedUp:
  336. MouseAccelerationSpeed++
  337. ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
  338. SetTimer, RemoveToolTip, 1000
  339. return
  340. ButtonAccelerationSpeedDown:
  341. If MouseAccelerationSpeed > 1
  342.     MouseAccelerationSpeed--
  343. If MouseAccelerationSpeed = 1
  344.     ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixel
  345. else
  346.     ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
  347. SetTimer, RemoveToolTip, 1000
  348. return
  349.  
  350. ButtonMaxSpeedUp:
  351. MouseMaxSpeed++
  352. ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
  353. SetTimer, RemoveToolTip, 1000
  354. return
  355. ButtonMaxSpeedDown:
  356. If MouseMaxSpeed > 1
  357.     MouseMaxSpeed--
  358. If MouseMaxSpeed = 1
  359.     ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixel
  360. else
  361.     ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
  362. SetTimer, RemoveToolTip, 1000
  363. return
  364.  
  365. ButtonRotationAngleUp:
  366. MouseRotationAnglePart++
  367. If MouseRotationAnglePart >= 8
  368.     MouseRotationAnglePart = 0
  369. MouseRotationAngle = %MouseRotationAnglePart%
  370. MouseRotationAngle *= 45
  371. ToolTip, Mouse rotation angle: %MouseRotationAngle%°
  372. SetTimer, RemoveToolTip, 1000
  373. return
  374. ButtonRotationAngleDown:
  375. MouseRotationAnglePart--
  376. If MouseRotationAnglePart < 0
  377.     MouseRotationAnglePart = 7
  378. MouseRotationAngle = %MouseRotationAnglePart%
  379. MouseRotationAngle *= 45
  380. ToolTip, Mouse rotation angle: %MouseRotationAngle%°
  381. SetTimer, RemoveToolTip, 1000
  382. return
  383.  
  384. ButtonUp:
  385. ButtonDown:
  386. ButtonLeft:
  387. ButtonRight:
  388. ButtonUpLeft:
  389. ButtonUpRight:
  390. ButtonDownLeft:
  391. ButtonDownRight:
  392. If Button <> 0
  393. {
  394.     IfNotInString, A_ThisHotkey, %Button%
  395.     {
  396.         MouseCurrentAccelerationSpeed = 0
  397.         MouseCurrentSpeed = %MouseSpeed%
  398.     }
  399. }
  400. StringReplace, Button, A_ThisHotkey, *
  401.  
  402. ButtonAccelerationStart:
  403. If MouseAccelerationSpeed >= 1
  404. {
  405.     If MouseMaxSpeed > %MouseCurrentSpeed%
  406.     {
  407.         Temp = 0.001
  408.         Temp *= %MouseAccelerationSpeed%
  409.         MouseCurrentAccelerationSpeed += %Temp%
  410.         MouseCurrentSpeed += %MouseCurrentAccelerationSpeed%
  411.     }
  412. }
  413.  
  414. ;MouseRotationAngle convertion to speed of button direction
  415. {
  416.     MouseCurrentSpeedToDirection = %MouseRotationAngle%
  417.     MouseCurrentSpeedToDirection /= 90.0
  418.     Temp = %MouseCurrentSpeedToDirection%
  419.  
  420.     if Temp >= 0
  421.     {
  422.         if Temp < 1
  423.         {
  424.             MouseCurrentSpeedToDirection = 1
  425.             MouseCurrentSpeedToDirection -= %Temp%
  426.             Goto EndMouseCurrentSpeedToDirectionCalculation
  427.         }
  428.     }
  429.     if Temp >= 1
  430.     {
  431.         if Temp < 2
  432.         {
  433.             MouseCurrentSpeedToDirection = 0
  434.             Temp -= 1
  435.             MouseCurrentSpeedToDirection -= %Temp%
  436.             Goto EndMouseCurrentSpeedToDirectionCalculation
  437.         }
  438.     }
  439.     if Temp >= 2
  440.     {
  441.         if Temp < 3
  442.         {
  443.             MouseCurrentSpeedToDirection = -1
  444.             Temp -= 2
  445.             MouseCurrentSpeedToDirection += %Temp%
  446.             Goto EndMouseCurrentSpeedToDirectionCalculation
  447.         }
  448.     }
  449.     if Temp >= 3
  450.     {
  451.         if Temp < 4
  452.         {
  453.             MouseCurrentSpeedToDirection = 0
  454.             Temp -= 3
  455.             MouseCurrentSpeedToDirection += %Temp%
  456.             Goto EndMouseCurrentSpeedToDirectionCalculation
  457.         }
  458.     }
  459. }
  460. EndMouseCurrentSpeedToDirectionCalculation:
  461.  
  462. ;MouseRotationAngle convertion to speed of 90 degrees to right
  463. {
  464.     MouseCurrentSpeedToSide = %MouseRotationAngle%
  465.     MouseCurrentSpeedToSide /= 90.0
  466.     Temp = %MouseCurrentSpeedToSide%
  467.     Transform, Temp, mod, %Temp%, 4
  468.  
  469.     if Temp >= 0
  470.     {
  471.         if Temp < 1
  472.         {
  473.             MouseCurrentSpeedToSide = 0
  474.             MouseCurrentSpeedToSide += %Temp%
  475.             Goto EndMouseCurrentSpeedToSideCalculation
  476.         }
  477.     }
  478.     if Temp >= 1
  479.     {
  480.         if Temp < 2
  481.         {
  482.             MouseCurrentSpeedToSide = 1
  483.             Temp -= 1
  484.             MouseCurrentSpeedToSide -= %Temp%
  485.             Goto EndMouseCurrentSpeedToSideCalculation
  486.         }
  487.     }
  488.     if Temp >= 2
  489.     {
  490.         if Temp < 3
  491.         {
  492.             MouseCurrentSpeedToSide = 0
  493.             Temp -= 2
  494.             MouseCurrentSpeedToSide -= %Temp%
  495.             Goto EndMouseCurrentSpeedToSideCalculation
  496.         }
  497.     }
  498.     if Temp >= 3
  499.     {
  500.         if Temp < 4
  501.         {
  502.             MouseCurrentSpeedToSide = -1
  503.             Temp -= 3
  504.             MouseCurrentSpeedToSide += %Temp%
  505.             Goto EndMouseCurrentSpeedToSideCalculation
  506.         }
  507.     }
  508. }
  509. EndMouseCurrentSpeedToSideCalculation:
  510.  
  511. MouseCurrentSpeedToDirection *= %MouseCurrentSpeed%
  512. MouseCurrentSpeedToSide *= %MouseCurrentSpeed%
  513.  
  514. Temp = %MouseRotationAnglePart%
  515. Transform, Temp, Mod, %Temp%, 2
  516.  
  517. If Button = NumPadUp
  518. {
  519.     if Temp = 1
  520.     {
  521.         MouseCurrentSpeedToSide *= 2
  522.         MouseCurrentSpeedToDirection *= 2
  523.     }
  524.  
  525.     MouseCurrentSpeedToDirection *= -1
  526.     MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
  527. }
  528. else if Button = NumPadDown
  529. {
  530.     if Temp = 1
  531.     {
  532.         MouseCurrentSpeedToSide *= 2
  533.         MouseCurrentSpeedToDirection *= 2
  534.     }
  535.  
  536.     MouseCurrentSpeedToSide *= -1
  537.     MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
  538. }
  539. else if Button = NumPadLeft
  540. {
  541.     if Temp = 1
  542.     {
  543.         MouseCurrentSpeedToSide *= 2
  544.         MouseCurrentSpeedToDirection *= 2
  545.     }
  546.  
  547.     MouseCurrentSpeedToSide *= -1
  548.     MouseCurrentSpeedToDirection *= -1
  549.  
  550.     MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
  551. }
  552. else if Button = NumPadRight
  553. {
  554.     if Temp = 1
  555.     {
  556.         MouseCurrentSpeedToSide *= 2
  557.         MouseCurrentSpeedToDirection *= 2
  558.     }
  559.  
  560.     MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
  561. }
  562. else if Button = NumPadHome
  563. {
  564.     Temp = %MouseCurrentSpeedToDirection%
  565.     Temp -= %MouseCurrentSpeedToSide%
  566.     Temp *= -1
  567.     Temp2 = %MouseCurrentSpeedToDirection%
  568.     Temp2 += %MouseCurrentSpeedToSide%
  569.     Temp2 *= -1
  570.     MouseMove, %Temp%, %Temp2%, 0, R
  571. }
  572. else if Button = NumPadPgUp
  573. {
  574.     Temp = %MouseCurrentSpeedToDirection%
  575.     Temp += %MouseCurrentSpeedToSide%
  576.     Temp2 = %MouseCurrentSpeedToDirection%
  577.     Temp2 -= %MouseCurrentSpeedToSide%
  578.     Temp2 *= -1
  579.     MouseMove, %Temp%, %Temp2%, 0, R
  580. }
  581. else if Button = NumPadEnd
  582. {
  583.     Temp = %MouseCurrentSpeedToDirection%
  584.     Temp += %MouseCurrentSpeedToSide%
  585.     Temp *= -1
  586.     Temp2 = %MouseCurrentSpeedToDirection%
  587.     Temp2 -= %MouseCurrentSpeedToSide%
  588.     MouseMove, %Temp%, %Temp2%, 0, R
  589. }
  590. else if Button = NumPadPgDn
  591. {
  592.     Temp = %MouseCurrentSpeedToDirection%
  593.     Temp -= %MouseCurrentSpeedToSide%
  594.     Temp2 *= -1
  595.     Temp2 = %MouseCurrentSpeedToDirection%
  596.     Temp2 += %MouseCurrentSpeedToSide%
  597.     MouseMove, %Temp%, %Temp2%, 0, R
  598. }
  599.  
  600. SetTimer, ButtonAccelerationEnd, 10
  601. return
  602.  
  603. ButtonAccelerationEnd:
  604. GetKeyState, kstate, %Button%, P
  605. if kstate = D
  606.     Goto ButtonAccelerationStart
  607.  
  608. SetTimer, ButtonAccelerationEnd, off
  609. MouseCurrentAccelerationSpeed = 0
  610. MouseCurrentSpeed = %MouseSpeed%
  611. Button = 0
  612. return
  613.  
  614. ;Mouse wheel movement support
  615.  
  616. ButtonWheelSpeedUp:
  617. MouseWheelSpeed++
  618. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  619. If MouseWheelSpeedMultiplier <= 0
  620.     MouseWheelSpeedMultiplier = 1
  621. MouseWheelSpeedReal = %MouseWheelSpeed%
  622. MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
  623. ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
  624. SetTimer, RemoveToolTip, 1000
  625. return
  626. ButtonWheelSpeedDown:
  627. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  628. If MouseWheelSpeedMultiplier <= 0
  629.     MouseWheelSpeedMultiplier = 1
  630. If MouseWheelSpeedReal > %MouseWheelSpeedMultiplier%
  631. {
  632.     MouseWheelSpeed--
  633.     MouseWheelSpeedReal = %MouseWheelSpeed%
  634.     MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
  635. }
  636. If MouseWheelSpeedReal = 1
  637.     ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% line
  638. else
  639.     ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
  640. SetTimer, RemoveToolTip, 1000
  641. return
  642.  
  643. ButtonWheelAccelerationSpeedUp:
  644. MouseWheelAccelerationSpeed++
  645. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  646. If MouseWheelSpeedMultiplier <= 0
  647.     MouseWheelSpeedMultiplier = 1
  648. MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
  649. MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
  650. ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
  651. SetTimer, RemoveToolTip, 1000
  652. return
  653. ButtonWheelAccelerationSpeedDown:
  654. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  655. If MouseWheelSpeedMultiplier <= 0
  656.     MouseWheelSpeedMultiplier = 1
  657. If MouseWheelAccelerationSpeed > 1
  658. {
  659.     MouseWheelAccelerationSpeed--
  660.     MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
  661.     MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
  662. }
  663. If MouseWheelAccelerationSpeedReal = 1
  664.     ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% line
  665. else
  666.     ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
  667. SetTimer, RemoveToolTip, 1000
  668. return
  669.  
  670. ButtonWheelMaxSpeedUp:
  671. MouseWheelMaxSpeed++
  672. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  673. If MouseWheelSpeedMultiplier <= 0
  674.     MouseWheelSpeedMultiplier = 1
  675. MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
  676. MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
  677. ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
  678. SetTimer, RemoveToolTip, 1000
  679. return
  680. ButtonWheelMaxSpeedDown:
  681. RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
  682. If MouseWheelSpeedMultiplier <= 0
  683.     MouseWheelSpeedMultiplier = 1
  684. If MouseWheelMaxSpeed > 1
  685. {
  686.     MouseWheelMaxSpeed--
  687.     MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
  688.     MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
  689. }
  690. If MouseWheelMaxSpeedReal = 1
  691.     ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% line
  692. else
  693.     ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
  694. SetTimer, RemoveToolTip, 1000
  695. return
  696.  
  697. ButtonWheelUp:
  698. ButtonWheelDown:
  699.  
  700. If Button <> 0
  701. {
  702.     If Button <> %A_ThisHotkey%
  703.     {
  704.         MouseWheelCurrentAccelerationSpeed = 0
  705.         MouseWheelCurrentSpeed = %MouseWheelSpeed%
  706.     }
  707. }
  708. StringReplace, Button, A_ThisHotkey, *
  709.  
  710. ButtonWheelAccelerationStart:
  711. If MouseWheelAccelerationSpeed >= 1
  712. {
  713.     If MouseWheelMaxSpeed > %MouseWheelCurrentSpeed%
  714.     {
  715.         Temp = 0.001
  716.         Temp *= %MouseWheelAccelerationSpeed%
  717.         MouseWheelCurrentAccelerationSpeed += %Temp%
  718.         MouseWheelCurrentSpeed += %MouseWheelCurrentAccelerationSpeed%
  719.     }
  720. }
  721.  
  722. If Button = NumPadSub
  723.     MouseClick, wheelup,,, %MouseWheelCurrentSpeed%, 0, D
  724. else if Button = NumPadAdd
  725.     MouseClick, wheeldown,,, %MouseWheelCurrentSpeed%, 0, D
  726.  
  727. SetTimer, ButtonWheelAccelerationEnd, 100
  728. return
  729.  
  730. ButtonWheelAccelerationEnd:
  731. GetKeyState, kstate, %Button%, P
  732. if kstate = D
  733.     Goto ButtonWheelAccelerationStart
  734.  
  735. MouseWheelCurrentAccelerationSpeed = 0
  736. MouseWheelCurrentSpeed = %MouseWheelSpeed%
  737. Button = 0
  738. return
  739.  
  740. RemoveToolTip:
  741. SetTimer, RemoveToolTip, Off
  742. ToolTip
  743. return
Advertisement
Add Comment
Please, Sign In to add comment