1

So hi,

I'd like to be able to change my Windows mouse key settings on the fly. To achieve this I was thinking some commands ran with a batch file (or anything else, doesn't have to be a batch file obviously) would be something that's possible(?). I could easily program a batch file to be ran by the press of a button with my keyboard.

Does anyone know if/how I could configure my mouse key settings without actually opening the ease of access center and going there? The thing I'd mainly be changing would be:
image

Any replies are highly appreciated, and remember, it doesn't have to be exactly what I said, I just want a way to achieve this. I'm open to any options, thanks.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • check [**this**](http://stackoverflow.com/questions/2931122/dynamically-changing-mouse-speed) and [**this**](http://www.dostips.com/forum/viewtopic.php?f=3&t=5260&start=15#p50787) – npocmaka Jan 26 '17 at 19:14
  • thanks @npocmaka I'll take a closer look at those when I can. Also, I found this: https://msdn.microsoft.com/en-us/library/windows/desktop/dd373593(v=vs.85).aspx I'd appreciate if someone who's smarter than me could take a look at that and tell if that's something I can use to achieve my goal. – user3840888 Jan 26 '17 at 19:57

1 Answers1

1

Make a text file which you can call swapmouse.cs, containing this:

using System.Runtime.InteropServices;
using System;

class SwapMouse
{
    [DllImport("user32.dll")]
    public static extern Int32 SwapMouseButton(Int32 bSwap);

    static void Main(string[] args)
    {
        int rightButtonIsAlreadyPrimary = SwapMouseButton(1);
        if (rightButtonIsAlreadyPrimary != 0)
        {
            SwapMouseButton(0);  // Make the left mousebutton primary
        }
    }
}

And compile it to swapmouse.exe with this command in a terminal window:

"%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc" swapmouse.cs

Just run the .exe file, if you want to get it back to it's original state, just run the .exe file again.

sgiraldoa
  • 11
  • 1