-1

bought a mouse from china and when i tried i realized thumb buttons are swapped was wondering with C# is it possible to switch these buttons

i was trying something like:

    switch(MouseButtons)
    {
    case MouseButtons.XButton1:
    MouseButtons.XButton2;
    break;

    case MouseButtons.XButton2:
    MouseButtons.XButton1;
    break;
    }

or maybe something with:

    MouseButtonState.Mouse.XButton1 == MouseButtonState.Pressed

and BTW im a 6monhts newbie with c#

maybe use window hooks? i read about it but i dont know how to apply it.

darkman00
  • 19
  • 5

2 Answers2

0

I think it can be done via Win API calls, like the keyboard hooks do, you can find samples anywhere.

But that method would be a little overcomplicated, it is much easier to download the program called AutoHotkey from here: http://ahkscript.org/ And use the script provided here by Masonjar13: http://www.autohotkey.com/board/topic/114669-swap-xbutton1-and-xbutton2/

Please note that a character (") is missing. I copy here the fixed solution for the future generations :D

$*XButton1::
SendInput {XButton2 down}
while(GetKeyState("XButton1","P"))
    sleep 10
SendInput {XButton2 up}
return

$*XButton2::
SendInput {XButton1 down}
while(GetKeyState("XButton2","P"))
    sleep 10
SendInput {XButton1 up}
return
-1

You can switch mouse buttons globally in Windows via Control Panel's applet Mouse.

Press Win+R -> type Control and press Enter -> locate Mouse -> check switch buttons

Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
MYSLIVEC
  • 1
  • 1