How do I use Rundll32 to swapmousebutton?

前端 未结 5 763
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 10:55

I\'m repeating a question from another forum, as I\'d like the same answer.

From MSDN\'s SwapMouseButton Function.

How do I pass boolean data from

5条回答
  •  时光说笑
    2021-02-06 11:13

    Thanks so much for the C# solution. It worked like a charm.

    I made a slight alteration so that I could simply click on a desktop short-cut to toggle the primary mouse button, without passing in arguments. In case my approach helps someone else, here is that version:

    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
            }
        }
    }
    

提交回复
热议问题