2

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.

Jonathan
  • 1,678
  • 10
  • 28
  • 47
  • 1
    This command works perfectly for me. You do not need to run this command as an administrator, because the setting of the mouse layout is saved under HKCU in the registry. – Norbert Willhelm Jun 25 '15 at 08:08

3 Answers3

2

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)

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
0

I used the text below on windows 10 and saved it as sandbox_mouse_button_swap.wsb

Double-clicking that file opens up the sandbox with the mouse buttons swapped, no reboot required.

<Configuration>
  <LogonCommand>
    <Command>rundll32.exe user32.dll,SwapMouseButton</Command>
  </LogonCommand>
</Configuration>
jt-pdx
  • 1
  • 2
0

I am no expert at this - I tried both the above solutions but it did not work and so I simply created a .bat file with the following command script, saved it to my Desktop and whenever I want to swap, I double-click the script to make it run and it does the job for me.

rundll32.exe user32.dll,SwapMouseButton

Vinny
  • 1