Changing mouse sensitivity on the fly.
Changing mouse sensitivity on the fly.
Here's a challenge for a Windows guru....
A game I'm playing has its mouse sensitivity set too high for me. Unfortunately the game developer didn't provide a setting to adjust this.
So I'm writing a small launcher for the game. The idea is to have the launcher lower the system's mouse sensitivity adjustment, run the game, then restore the sensitivity setting after the game exits.
I've already found where in the registry the setting is store and have already written the program, all except for one thing...
As I suspected, it turns out that just changing the setting in the registry isn't enough. After changing the setting, I need a way to tell Windows to go get the new setting and start using it.
Anyone know how to do this?
Thanks!
A game I'm playing has its mouse sensitivity set too high for me. Unfortunately the game developer didn't provide a setting to adjust this.
So I'm writing a small launcher for the game. The idea is to have the launcher lower the system's mouse sensitivity adjustment, run the game, then restore the sensitivity setting after the game exits.
I've already found where in the registry the setting is store and have already written the program, all except for one thing...
As I suspected, it turns out that just changing the setting in the registry isn't enough. After changing the setting, I need a way to tell Windows to go get the new setting and start using it.
Anyone know how to do this?
Thanks!
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Matt wrote:Please share?
Code: Select all
MouseAccel = 10 ; Maximum = 20
SystemParametersInfo_(#SPI_SETMOUSESPEED,0,MouseAccel,0)
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
I will, or would have, once I had something working, no point sending you on one of my wild goose chases....Matt wrote:Please share?

Where did you find that?
The info I have makes no mention of SPI_SETMOUSESPEED, all it has is SPI_GETMOUSE and SPI_SETMOUSE which didn't work....

Never mind, as much as I don't like M$'s documentation, I found it in the MSDN Library I got with Visual Studio 6, guess I'll have to reload it and dump this old documentation I've been using.... :p
Last edited by Tipperton on Sun Apr 01, 2007 12:14 am, edited 1 time in total.
Infos here: http://msdn2.microsoft.com/en-us/library/ms724947.aspx
and to make effekt here: http://msdn2.microsoft.com/en-us/library/ms725497.aspx
I hope this help you
and to make effekt here: http://msdn2.microsoft.com/en-us/library/ms725497.aspx
I hope this help you
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Hmm... must be something more to it than that....
Had no effect no matter what value lNewSensitivity has.
Ooops! Not a pointer for SET...
It works now....
Correct code is:
Code: Select all
lNewSensitivity=1
SystemParametersInfo_(#SPI_SETMOUSESPEED, 0, @lNewSensitivity, #SPIF_SENDWININICHANGE)
Ooops! Not a pointer for SET...
It works now....

Correct code is:
Code: Select all
SystemParametersInfo_(#SPI_GETMOUSESPEED, 0, @lNewSensitivity, 0)
SystemParametersInfo_(#SPI_SETMOUSESPEED, 0, lNewSensitivity, #SPIF_SENDWININICHANGE)
Last edited by Tipperton on Tue Apr 03, 2007 12:44 am, edited 1 time in total.
It's specified that way in the documentation:Tipperton wrote:...
Microsoft's docs say that the third parameter has to be a pointer so I put the @ sign in there.
...
Notice that you need the @ when getting the parameters, but don't need it when you are setting them.... weird....
MSDN docs for SPI_GETMOUSESPEED wrote:...
The pvParam parameter must point to an integer that receives a value ...
Though I don't really understand why they wouldn't keep it consistent and also require a pointer for pvParam when setting the speed. Good ol' MS.MSDN docs for SPI_SETMOUSESPEED wrote:...
The pvParam parameter is an integer between 1 (slowest) and 20 (fastest)...

"Ahead one third... ahead two thirds... Full ahead flank
And out from the belly of the whale came a prophet, Amen"
And out from the belly of the whale came a prophet, Amen"
Ooops!Clutch wrote:Though I don't really understand why they wouldn't keep it consistent and also require a pointer for pvParam when setting the speed. Good ol' MS.

I only read the docs for SPI_GETMOUSESPEED and figured it would be consistant for SPI_SETMOUSESPEED.
Count on M$ to find ways to throw curve balls at us....
Anyway, although it worked, it only worked for part of the game, apparently in menued sections without a lot of animation they use the standard Windows mouse routines, but for the rest of the game that has a lot of animation, they use DirectInput which apparently ignores the system mouse settings.
Not even going to try setting the DirectInput sensitivity because the game probably would reset it to the value they chose when they initialize DirectInput....
Oh well.... If nothing else I learned a few things in this excercize so it wasn't a total loss.

- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Hm,
does anyone know, which of these two lines should be used...
Michael
does anyone know, which of these two lines should be used...
Code: Select all
*MouseInfo=18
SystemParametersInfo_(#SPI_SETMOUSESPEED,#Null,*MouseInfo,#SPIF_SENDWININICHANGE)
SystemParametersInfo_(#SPI_SETMOUSESPEED,#Null,*MouseInfo,#SPIF_UPDATEINIFILE)
What game is it? Most games have a config file of sorts and you may be able to enter the sensitivity there. (then set the readonly flag on the file so the game can't change it) if lucky it will use the setting. (avoid changing the config in the game obviously).
Also, what mouse? If it's a Microsoft or Logitech or Saitek then they do have mouse apps that let you make profiles for your game(s) etc.
The Microsoft app (Intellimouse?) "might" also work on any Microsoft mouse compatible mouse.
Also, what mouse? If it's a Microsoft or Logitech or Saitek then they do have mouse apps that let you make profiles for your game(s) etc.
The Microsoft app (Intellimouse?) "might" also work on any Microsoft mouse compatible mouse.