Saturday 30 March 2019

How do you swap the primary mouse button via commandline in Windows 8 without a reboot?


I've tried


RUNDLL32.EXE USER32.DLL,SwapMouseButton

But it doesn't work, even when run as administrator.


My goal is to make a .bat file that I can call via my fancy shmancy new mouse I bought that allows me to call any arbitrary command from a mouse click.



Answer



Swap mouse buttons from command line



We can swap mouse buttons by editing the registry value SwapMouseButtons under the registry key HKEY_CURRENT_USER\Control Panel\Mouse. To swap mouse buttons we need to set its value to 1.


Same thing can be done from command line using the below command.


reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v SwapMouseButtons /t REG_SZ /d 1

It requires a logoff or reboot to make the changes effective.


Reference Swap mouse buttons from command line:




Alternative Solution


How do I use Rundll32 to swapmousebutton? for a C# solution (requires the .NET Framework Runtime to be installed)


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...