Skip to content

Instantly share code, notes, and snippets.

@rtldg
Last active April 22, 2022 00:52
Show Gist options
  • Save rtldg/e002065e003cb45409ea34e64ddcdb6d to your computer and use it in GitHub Desktop.
Save rtldg/e002065e003cb45409ea34e64ddcdb6d to your computer and use it in GitHub Desktop.
#include <Windows.h>
#include <iostream>
#define NEW_SENS 1
int main()
{
std::cout << "Hello World!\n";
unsigned original_sens;
if (!SystemParametersInfoW(SPI_GETMOUSESPEED, 0, &original_sens, 0))
{
return 1;
}
// Simple check to see if we can even change the mousespeed...
if (!SystemParametersInfoW(SPI_SETMOUSESPEED, 0, (PVOID)original_sens, 0))
{
return 1;
}
while (1)
{
CURSORINFO ci = { 0 };
ci.cbSize = sizeof(ci);
if (!GetCursorInfo(&ci) || ci.flags) // flags = 0 when cursor hidden
{
SystemParametersInfoW(SPI_SETMOUSESPEED, 0, (PVOID)original_sens, 0);
}
else
{
SystemParametersInfoW(SPI_SETMOUSESPEED, 0, (PVOID)NEW_SENS, 0);
}
Sleep(8);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment