Sign in to follow this  
Followers 0
LoWang

enhance mouse precision switch on/off

5 posts in this topic

Hello, I am trying to make a script or reg file to switch on and off "enhance pointer precision" which is generally a mouse acceleration you can set in control panel. I was trying to find what's happening in registry via sysinternals Process Monitor, but did not see anything interesting. Then I found that a value HKEY_CURRENT_USER\Control Panel\Mouse\MouseSpeed switches between 0 an 1 when I check/uncheck this in control panel, but it is probably not the only thing! Because When I change this manualy it does not do anything and the mouse settings remains unchanged... What do you think? I was trying to find some WMI method but failed...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You most probably need to make "refresh"/update it's settings from the registry, I'm leaning towards some DllCall, or WMI method. I recall seeing code to do this somewhere in this forum, can't remember the name of the thread though. :/

Edit:

I ended up making this, which seems to work like it should(changes the same settings that ticking/unticking the "enhance mouse pointer precision" in the mouse settings panel does):

_EnableMouseAccel(False)
If @error Then MsgBox(0, "Error", "An error occured: " & @error)

Func _EnableMouseAccel($ivState)
    
    Local Const $SPI_SETMOUSE = 4
    Local Const $SPIF_UPDATEINIFILE = 1
    Local Const $SPIF_SENDWININICHANGE = 2

    Local $mouseStruct = DllStructCreate("int[3]")
    
    DllStructSetData($mouseStruct, 1, 6*$ivState, 1)
    DllStructSetData($mouseStruct, 1, 10*$ivState, 2)
    DllStructSetData($mouseStruct, 1, $ivState, 3)
    
    Local $avResult = DllCall("user32.dll", "int", "SystemParametersInfo", "uint", $SPI_SETMOUSE, "uint", 0, "ptr", DllStructGetPtr($mouseStruct), "uint",  BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
    If @error Or Not $avResult[0] Then Return(SetError(1, 0, 0)) ; Failed to update settings
    
EndFunc
Edited by FreeFry

Share this post


Link to post
Share on other sites

Great, thank you very much! I will now change my Half-Life 2 shortcuts to do this script first and then run the game :-))

Share this post


Link to post
Share on other sites

Or you could code your script to turn off mouse accel, then run the game. :)

Share this post


Link to post
Share on other sites

Hey...

Im having a little trouble following your "guide", but it sounds like it should work.

What i do is that i copy the script that you wrote and put in a .txt file. Then i name the file mousefix.reg, but when i run it, an error message tells me that the code isn't a reg file... What do i do wrong?

\\Kristoffer

A little subquestion ;)

You agree on that this should disable my mouseacceleration in counterstrike 1.6 right? :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0