Reputation: 1505
I was sucecssful regarding changing the mouse speed with C# with the help of this article: http://www.sparrowtail.com/changing-mouse-pointer-speed-c.
Now I also want to get the current mouse speed. I tried to change const uint SPI_GETMOUSESPEED
to 0x0072
and also to 0x0070
hoping that this would be the right adress. Microsoft documentation says that the adress (at least in C++) is 0x70
however it is not possbile for me to get the right adress on the internet.
My function:
private int GetMouseSpeed()
{
const uint SPI_GETMOUSESPEED = 0x0070;
uint mouseSpeed = 0;
SystemParametersInfo
(
SPI_GETMOUSESPEED,
0,
mouseSpeed,
0
);
return (int) mouseSpeed;
}
Upvotes: 0
Views: 2945
Reputation: 5135
You can find all possible values of uiAction
on the MSDN. SPI_GETMOUSESPEED
value is 0x70
. Plus, you need to pass pointer to an integer that receives a value. In the code below I did it using the unsafe &
operator. In order to compile it, you need to check Allow unsafe context
in the build settings of your project.
public const UInt32 SPI_GETMOUSESPEED = 0x0070;
[DllImport("User32.dll")]
static extern Boolean SystemParametersInfo(
UInt32 uiAction,
UInt32 uiParam,
IntPtr pvParam,
UInt32 fWinIni);
static unsafe void Main(string[] args)
{
int speed;
SystemParametersInfo(
SPI_GETMOUSESPEED,
0,
new IntPtr(&speed),
0);
Console.WriteLine(speed);
}
Upvotes: 3