windows - 如何使用 Rundll32 来交换鼠标按钮?

标签 windows mouse rundll32

我正在重复另一个论坛的问题,因为我想要相同的答案。

来自 MSDN 的 SwapMouseButton Function .

How do I pass boolean data from command prompt through rundll32.exe to a boolean type argument in a command running from user32.dll?

I'm trying to run this from CMD (the command prompt)

RUNDLL32.EXE user32.dll,SwapMouseButton *

Where the asterisk is here is where the argument should go. I already ran it without an argument and it swapped my left and right mouse buttons (seems TRUE is the default entry for the boolean argument). Now I want to undo it. However I've tried each of these for passing FALSE in the argument, and none have worked (none set my mouse buttons back to normal).

  • F
  • f
  • false
  • False
  • FALSE
  • "false"
  • "False"
  • "FALSE"
  • 0
  • -1

Please help me pass the argument as needed. Thanks in advance.

最佳答案

非常感谢 C# 解决方案。它就像一个魅力。

我做了一些细微的改动,这样我就可以简单地点击桌面快捷方式来切换主鼠标按钮,而无需传递参数。如果我的方法对其他人有帮助,这里是那个版本:

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

关于windows - 如何使用 Rundll32 来交换鼠标按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4806575/

相关文章:

windows - 为什么 Rust 在构建 DLL 时导出其整个标准库?

windows - 如何解决 Arduino 中的内存错误?

javascript - Flash:即使在舞台/浏览器之外,也可以在单击并拖动(向下移动)后跟踪鼠标位置?

python - Tkinter 看透窗口不受鼠标点击影响

python - BAT运行python并在一段时间后杀死它

c++ - 如何获取在桌面等文件夹路径中突出显示的快捷方式和文件

java - 启动相关程序或显示来自另一个程序的 "Open with"对话框

vb.net - “RUNDLL32 PRINTUI.DLL,PrintUIEntry/Sr/n...操作无法完成(错误 0x0000000c)

c++ - SendInput - (鼠标移动模拟)

qt - 有没有办法从 FileProtocolHandler 或 url.dll 获取错误级别?