我正在重复另一个论坛的问题,因为我想要相同的答案。
来自 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/