batch file - Automatically disable mouse acceleration - Windows -
i have laptop , use mouse it. don't acceleration while using mouse. have disable acceleration every time plug mouse. there way automatically disable mouse acceleration, whenever plug mouse? know u can script un udev recognizes mouse plugged , auto disable mouse acceleration... how do on windows ?
believe not possible simple batch-file. can use windows api in c++:
you can register device notifications (like plugging in usb mouse) using registerdevicenotification
handle hrecipient = hwnd; // window handle returned createwindow guid interfaceclassguid = { 0x378de44c, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd }; // guid_devinterface_mouse dev_broadcast_deviceinterface notificationfilter; zeromemory(¬ificationfilter, sizeof(notificationfilter)); notificationfilter.dbcc_size = sizeof(dev_broadcast_deviceinterface); notificationfilter.dbcc_devicetype = dbt_devtyp_deviceinterface; notificationfilter.dbcc_classguid = interfaceclassguid; hdevnotify hdevicenotify = registerdevicenotification(hrecipient, ¬ificationfilter, device_notify_window_handle); if (hdevicenotify == null) { getlasterror(); // error handling here }
and listen them in window's message handler (lresult callback
wndproc
(hwnd hwnd, uint message, wparam wparam, lparam lparam)
)
switch (message) { case wm_devicechange: switch (wparam) { case dbt_devicearrival: // mouse plugged in - turn mouse acceleration off here break; case dbt_deviceremovecomplete: // mouse removed - turn mouse acceleration on here break; default: break; } break; case // ... usual window message handling
actually changing setting can achieved using systemparametersinfo
described in this excellent answer.
i implemented tiny tool called accelswitcher that. available on github.
Comments
Post a Comment