mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-27 10:15:50 +08:00
27 lines
848 B
C#
27 lines
848 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace BetterGenshinImpact.Helpers.Device;
|
|
|
|
public class MouseSpeedSettings
|
|
{
|
|
// Import the SystemParametersInfo function from the user32.dll
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
private static extern bool SystemParametersInfo(
|
|
uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
|
|
|
|
// Constants for SystemParametersInfo function
|
|
private const uint SPI_GETMOUSESPEED = 0x0070;
|
|
private const uint SPI_SETMOUSESPEED = 0x0071;
|
|
|
|
|
|
public static void SetMouseSpeed(uint speed)
|
|
{
|
|
if (speed < 1 || speed > 20)
|
|
{
|
|
throw new ArgumentOutOfRangeException(nameof(speed), "Mouse speed must be between 1 and 20.");
|
|
}
|
|
|
|
SystemParametersInfo(SPI_SETMOUSESPEED, 0, speed, 0);
|
|
}
|
|
} |