Skip to content

Instantly share code, notes, and snippets.

@GaliTW
Last active December 23, 2021 23:17
Show Gist options
  • Save GaliTW/6e6ad060aedb15b10b51429b3281e7fc to your computer and use it in GitHub Desktop.
Save GaliTW/6e6ad060aedb15b10b51429b3281e7fc to your computer and use it in GitHub Desktop.
AutoHotKey's script for Sniper Mode(Left Windows Key + N Key)
; Example: This is a hotkey that temporarily reduces the mouse cursor's speed, which facilitates precise positioning.
; Hold down the Hot key to slow down the cursor. Release it to return to original speed.
LWin & n::
SPI_GETMOUSESPEED = 0x70
SPI_SETMOUSESPEED = 0x71
; Retrieve the current speed so that it can be restored later:
DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, 0, UIntP, OrigMouseSpeed, UInt, 0)
; Now set the mouse to the slower speed specified in the next-to-last parameter (the range is 1-20, 10 is default):
DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, UInt, 10, UInt, 0)
KeyWait, LWin, n; This prevents keyboard auto-repeat from doing the DllCall repeatedly.
return
LWin & n up::DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, OrigMouseSpeed, UInt, 0) ; Restore the original speed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment