3

I have a laptop and I often use a mouse with it. I don't like acceleration while using the mouse. Thus I have to disable the acceleration every time I plug the mouse. Is there a way to automatically disable mouse acceleration, whenever I plug my mouse? I know that u can do a script un udev so it recognizes mouse plugged and auto disable mouse acceleration... but how do i do it on Windows ?

Lucca Lu
  • 33
  • 1
  • 4
  • mouse settings are stored here : HKEY_CURRENT_USER\Control Panel\Mouse - check through regedit if there's the thing you want. – npocmaka Jun 14 '15 at 08:56
  • And why do you not open __Control Panel - Mouse__ while the mouse is plugged in and configure the mouse acceleration parameters once for that mouse? Windows remembers the settings for each mouse. – Mofi Jun 14 '15 at 14:59
  • Actually, when i configure the mouse acceleration option for my mouse, it also changes for my touchpad... Are you sure there is such a thing? or maybe im just doing it wrong ? – Lucca Lu Jun 14 '15 at 18:55
  • For touch pads there is always a separate driver from the manufacturer of the laptop. The special settings for the touch pad can be accessed via __Control Panel - Mouse__ with this driver being installed. So it is possible to setup the general acceleration for generic mice and special acceleration settings for touch pad (and for pointing stick). The generic mouse acceleration setting is stored in Windows registry with value `MouseSensitivity` under `HKCU\Control Panel\Mouse` and could be modified with `reg add ...`. Run `reg add /?` in a command prompt window for details on this command. – Mofi Jun 15 '15 at 14:29
  • It depends on the driver if it has this extra setting implemented. Mine (and I guess the OP's) touch pad's doesn't. – jan-glx Aug 22 '16 at 16:49

1 Answers1

3

I believe this is not possible with a simple batch-file. However you can use the Windows API in c++:

You can register for device notifications (like plugging in an USB mouse) using RegisterDeviceNotification

HANDLE hRecipient = hWnd; // your window handle as returned by CreateWindow

GUID InterfaceClassGuid = { 0x378de44c, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 
                            0x14, 0x05, 0xdd }; // GUID_DEVINTERFACE_MOUSE
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;

ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
NotificationFilter.dbcc_classguid = InterfaceClassGuid;

HDEVNOTIFY hDeviceNotify = RegisterDeviceNotification(hRecipient, &NotificationFilter, 
                                                      DEVICE_NOTIFY_WINDOW_HANDLE);
if (hDeviceNotify == NULL) {
    GetLastError(); // do error handling here
}

and listen to them in your window's message handler (LRESULT CALLBACKWndProc(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 // ... your usual window message handling

actually changing the setting can be achieved using SystemParametersInfo as described in this excellent answer.


I implemented a tiny tool called accelSwitcher that does just that. It is available on github.

Community
  • 1
  • 1
jan-glx
  • 7,611
  • 2
  • 43
  • 63