Simple script to change mouse sensitivity

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
sf32
Posts: 2
Joined: 10 May 2018, 07:03

Simple script to change mouse sensitivity

10 May 2018, 08:01

Hi,
I tried to use some of the example code "hotkey that temporarily reduces the mouse cursor's speed" (F1) found in
https://autohotkey.com/docs/commands/DllCall.htm
to set specific mouse sensitivities when switching between the touchpad and an external mouse, as described in e.g.
https://www.howtogeek.com/howto/45366/h ... nal-mouse/
I tried both

Code: Select all

#F1:: 
SPI_SETMOUSESPEED = 0x71
DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, Ptr, 20, UInt, 0)
to speed up the mouse ("Ptr, 20", when using the touchpad),
and YatriTrivedi's suggestion

Code: Select all

#F1::DllCall(“SystemParametersInfo”, Int,113, Int,0, UInt,20, Int,2) ;high sensitivity
Executing the script as a standard user (it defeats the purpose if I have to switch to my Admin account), neither of these 2 options seem to change the sensitivity for the touchpad nor for the external mouse.
As far as I can tell, the only difference between the 2 options above (given the hex/dec conversions) is the last parameter for SPI:
"UInt, 0" = "Int, 0" vs. "Int,2".

As noted, neither of those options have any impact on the mouse sensitivity (I tried several other speed settings: "Ptr, 20", "Ptr, 10", "Ptr, 5").
When I open the Mouse Properties -> Pointer Options, the pointer speed remains at my default = mid point (10).

In contrast, the powershell method suggested by Marcus Müller, LogicLink in
https://gallery.technet.microsoft.com/s ... d-9ba16d0f
works like a charm: Within a couple of seconds, the mouse changes to the new sensitivity, and the Mouse Properties -> Pointer Options also get updated accordingly.

Given the elegancy of AHK scripts, I would really prefer to get it to work instead, esp. since the AHK script or a compiled version is easibly portable to other setups, unlike the PS solution.

I'd appreciate some enlightenment ...
THANKS!
sf32
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Simple script to change mouse sensitivity

11 May 2018, 06:01

Please clarify what you mean by "Sensitivity"
Are you talking about how the pointer reacts to input solely on the desktop, or are you talking about how games react to mouse input?
If the latter, they do not use windows sensitivity settings at all, so you will see no difference, as games are influenced by DPI, not sensitivity.

If you want to see some techniques for manipulating DPI / Sensitivity etc, then see some of my projects:
MouseDelta - Pure RawInput in AHK
RawInput POC using a C# DLL from AHK: - RawInput implemented in C#, loaded from AHK. Also contains examples using a combination of RawInput and Windows Hooks to alter sensitivity of a specific mouse.
AutoHotInterception Allows you to interface with the Interception custom driver - allows per-device blocking and altering. Super low-level and able to properly manipulate input **before it is seen by Windows**
User avatar
sf32
Posts: 2
Joined: 10 May 2018, 07:03

Re: Simple script to change mouse sensitivity

16 May 2018, 06:35

@evilC - Good point: There is a difference between the Mouse Sensitivity or actually the "Pointer Speed" setting in Windows that I refered to per the howtogeek article, and the "raw" DPI setting that is used by most games.
I am just looking for convenient solutions to fix the differences in Windows' effective DPI settings between e.g. an external mouse and trackpad, for use with regular Windows and SW that uses the Windows-provided mouse interface - not games, which often use a direct mouse interface.

Thanks for your project links - I'll check it out!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: SimmoF, uchihito and 217 guests