Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Adjusting Mouse Sensitivity via hotkey

  • Please log in to reply
19 replies to this topic
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Smaller code :) (reqires AHK_H).
Class _MouseSpeed {

   Get:=DynaCall("SystemParametersInfo",["uiuiui*ui",3],SPI_GETMOUSESPEED := 0x70)

   Set:=DynaCall("SystemParametersInfo",["uiuitui",3],SPI_SETMOUSESPEED := 0x71)


ms := new _MouseSpeed

ms.get[OrigMouseSpeed] ; get origial mouse speed

InputBox,NewSpeed,Enter New Mouse Speed,Current Speed: %OrigMouseSpeed%

ms.set[NewSpeed] ; set/write new speed

ms.get[OrigMouseSpeed] ; get/read new speed

MsgBox New Speed was changed to %OrigMouseSpeed%

  • Members
  • 54 posts
  • Last active: Sep 03 2013 05:59 PM
  • Joined: 16 Mar 2012
Very nice example, but it doesn't work ingame.
I tried to set last parameter of SystemParametersInfo to 0, 1 and 2 - it doesn't make any sense.
Any ideas?

  • Members
  • 1 posts
  • Last active: Dec 21 2012 01:02 PM
  • Joined: 21 Dec 2012

Something to share on the subject with a simple script to toggle between low and user sensitivity:

; Autohotkey script "Toggle Mouse sensitivity"
SlowMouseSpeed      := 1
NormalMouseSpeed    := true ; State of Mouse pointer speed
UserMouseSpeed      := 0    ; Speed sensed before slow down
MouseThreshold1     := 6
MouseThreshold2     := 10
MouseEnhance        := 1

SPI_SETMOUSE        := 0x04 

*F17::   toggleMouseSpeed()

toggleMouseSpeed() {
    if( NormalMouseSpeed )
        ; SENSE BEFORE
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)

        ; Temporarily reduces the mouse cursor's speed.
        ; Retrieve the current speed so that it can be restored later
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,UserMouseSpeed, UInt,0)
        ; Slow down mouse speed
        DllCall("SystemParametersInfo", UInt,SPI_SETMOUSESPEED, UInt,0, UInt,SlowMouseSpeed, UInt,0)

        ; SENSE AFTER
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
        ToolTip, Mouse slow: %currentSpeed%/20

        NormalMouseSpeed := false
    else {
        ; SENSE BEFORE
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,prevSpeed, UInt,0)

        ; Restore the original speed.
        DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt,0, UInt,UserMouseSpeed, UInt,0)

        ; Restore the original speed acceleration thresholds and speed
        VarSetCapacity(MySet, 32, 0) 
        InsertInteger(MouseThreshold1, MySet, 0)
        InsertInteger(MouseThreshold2, MySet, 4)
        InsertInteger(MouseEnhance   , MySet, 8)
        DllCall("SystemParametersInfo", UInt,SPI_SETMOUSE, UInt,0, Str,MySet, UInt,1) 

        ; SENSE AFTER
        DllCall("SystemParametersInfo", UInt,SPI_GETMOUSESPEED, UInt,0, UIntP,currentSpeed, UInt,0)
        ToolTip, Mouse restored: %currentSpeed%/20

        NormalMouseSpeed := true
    SetTimer, RemoveToolTip, 1000
InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) {
    ; Copy each byte in the integer into the structure as raw binary data. 
    Loop %pSize%
    DllCall("RtlFillMemory", "UInt",&pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) 
SetTimer, RemoveToolTip, Off



Problem with that code is that it re-enables mouse acceleration. It doesn't leave your mouse settings untouched when you disable the script again.


I'm looking for a script which will, on a keypress, toggle your mouse sensitivity to maximum, and back to what it was when you press it again. It has to work inside games as well. Anyone have a script which does this?

  • Members
  • 1 posts
  • Last active: Jul 19 2013 06:31 PM
  • Joined: 18 Jul 2013

Hey, after reading through a few posts on anti-recoil for shooters, I was wondering if there is a way to make it where when you move the mouse 1 pixel it moves 2 or 3.

This would allow you to inscrease and decrease the sensitivity very quickly without having to change settings. This could be done with hotkeys, or actually making it enable or disable when you select a weapon.

Say you have a sniper rifle set to key "2" make it when you hit "2" that it turns the script off and goes to normal sensitivity, but when you hit "1" for say an assualt rifle, it will turn the script on and essentially double or tripple the dpi.

Thinking along the lines of base (low sensitivity) being around 300 dpi, making it where it doubles or triples it to 600 to 900, then just bump your base to around 400 would make it go to 800 or 1200. So it would still be very adjustable, if it's possible.

At work now so I don't have time to toy with creating a script, and I'm unsure if you can even modify horizontal mouse movement, but if someone else does I think it may work.


  • Members
  • 9 posts
  • Last active: Oct 08 2015 05:17 PM
  • Joined: 04 Aug 2013

Here's the script I use for working in photoshop etc.

MouseSens := 0
	MouseSens := !MouseSens
	ToolTip, % ("Precision: " . ((MouseSens = 1) ? "On" : "Off"))
	sleep 500

#if MouseSens
	~LShift::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,1, Int,2)
	~LShift Up::DllCall("SystemParametersInfo", Int,113, Int,0, UInt,10, Int,2)

The mouse precision mode is disabled at first when the scripts runs, and can be toggled with Win+F8.

When the mode is enabled, holding left shift sets the mouse speed to 1, releasing left shift sets the speed to 10 (middle of the available range).