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

9,623

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)

Share:
9,623

Related videos on Youtube

Jonathan
Author by

Jonathan

Knows 25 computer languages. Former global technical director at DreamWorks Animation SKG. Up for hire for web, app, game, & VR dev http://leadersandco.com

Updated on September 18, 2022

Comments

  • Jonathan
    Jonathan over 1 year

    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.

    • Norbert Willhelm
      Norbert Willhelm almost 9 years
      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.
  • Jonathan
    Jonathan over 9 years
    Unfortunately, by doing this, it requires a reboot. Which doesn't work since I want to be able to call this at will during work.
  • DavidPostill
    DavidPostill over 9 years
    Please edit your question to include this new requirement... :/
  • DavidPostill
    DavidPostill over 9 years
    @JonathanLeaders alternative solution added