Guest User

Untitled

a guest
Jul 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. ; Autohotkey script "Toggle Mouse sensitivity"
  2. ;=================================================================================
  3. SlowMouseSpeed := 1
  4. NormalMouseSpeed := true ; State of Mouse pointer speed
  5. UserMouseSpeed := 0 ; Speed sensed before slow down
  6. MouseThreshold1 := 6
  7. MouseThreshold2 := 10
  8. MouseEnhance := 1
  9.  
  10. SPI_GETMOUSESPEED := 0x70
  11. SPI_SETMOUSESPEED := 0x71
  12. SPI_SETMOUSE := 0x04
  13.  
  14. ;=================================================================================
  15. *F17:: toggleMouseSpeed()
  16.  
  17. ;=================================================================================
  18. toggleMouseSpeed() {
  19. global
  20. ; SET LOW SPEED
  21. if( NormalMouseSpeed )
  22. {
  23. ; SENSE BEFORE
  24. DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)
  25.  
  26. ; Temporarily reduces the mouse cursor's speed.
  27. ; Retrieve the current speed so that it can be restored later
  28. DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,UserMouseSpeed, UInt,0)
  29. ; Slow down mouse speed
  30. DllCall("SystemParametersInfo", UInt,SPI_SETMOUSESPEED, UInt,0, UInt,SlowMouseSpeed, UInt,0)
  31.  
  32. ; SENSE AFTER
  33. DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
  34. ToolTip, Mouse slow: %currentSpeed%/20
  35.  
  36. ; REMEMBER CURRENT STATE
  37. NormalMouseSpeed := false
  38. }
  39. ; RESTORE SPEED
  40. else {
  41. ; SENSE BEFORE
  42. DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)
  43.  
  44. ; Restore the original speed.
  45. DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt,0, UInt,UserMouseSpeed, UInt,0)
  46.  
  47. ; Restore the original speed acceleration thresholds and speed
  48. VarSetCapacity(MySet, 32, 0)
  49. InsertInteger(MouseThreshold1, MySet, 0)
  50. InsertInteger(MouseThreshold2, MySet, 4)
  51. InsertInteger(MouseEnhance , MySet, 8)
  52. DllCall("SystemParametersInfo", UInt,SPI_SETMOUSE, UInt,0, Str,MySet, UInt,1)
  53.  
  54. ; SENSE AFTER
  55. DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
  56. ToolTip, Mouse restored: %currentSpeed%/20
  57.  
  58. ; REMEMBER CURRENT STATE
  59. NormalMouseSpeed := true
  60. }
  61. SetTimer, RemoveToolTip, 1000
  62. }
  63. ;=================================================================================
  64. InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) {
  65. ; Copy each byte in the integer into the structure as raw binary data.
  66. Loop %pSize%
  67. DllCall("RtlFillMemory", "UInt",&pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
  68. }
  69. ;=================================================================================
  70. RemoveToolTip:
  71. SetTimer, RemoveToolTip, Off
  72. ToolTip
  73. return
  74.  
  75. ;=================================================================================
Add Comment
Please, Sign In to add comment