Untitled
using System; using System.Runtime.InteropServices; using System.Threading; class Program { // Import funkcji API Windows [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int fuWinIni); const int SPI_GETMOUSESPEED = 0x0070; const int SPI_SETMOUSESPEED = 0x0071; static void Main(string[] args) { int desiredSpeed = 10; // Prędkość wskaźnika (1-20) Console.WriteLine("Monitoring mouse speed..."); while (true) { // Pobierz aktualną prędkość wskaźnika int currentSpeed = GetMouseSpeed(); // Jeśli prędkość została zmieniona, przywróć żądaną wartość if (currentSpeed != desiredSpeed) { Console.WriteLine($"Mouse speed changed to {currentSpeed}. Restoring to {desiredSpeed}."); SetMouseSpeed(desiredSpeed); } // Odczekaj chwilę, aby nie obciążać CPU Thread.Sleep(500); // 500 ms } } static int GetMouseSpeed() { int speed = 0; SystemParametersInfo(SPI_GETMOUSESPEED, 0, ref speed, 0); return speed; } static void SetMouseSpeed(int speed) { SystemParametersInfo(SPI_SETMOUSESPEED, 0, ref speed, 0); } }
Leave a Comment