如何使用 Rundll32 来交换鼠标按钮?
我重复另一个论坛的问题,因为我想要相同的答案。
来自 MSDN 的 SwapMouseButton 函数。
如何将命令提示符中的布尔数据通过 rundll32.exe 传递到从 user32.dll 运行的命令中的布尔类型参数?
我正在尝试从 CMD(命令提示符)运行此命令
RUNDLL32.EXE user32.dll,SwapMouseButton *
这里星号所在的位置就是参数应该去的地方。我已经在没有参数的情况下运行了它,并且它交换了我的鼠标左键和右键(似乎 TRUE 是布尔参数的默认条目)。现在我想撤消它。 然而,我已经尝试过在参数中传递 FALSE 的每一个,但没有一个起作用(没有一个将我的鼠标按钮设置回正常)。
- F
- f
- 假
- 错误
- 错误
- “假”
- “错误”
- “错误”
- 0
- -1
请帮我根据需要传递论点。提前致谢。
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
非常感谢 C# 解决方案。它就像一个魅力。
我做了一些小小的修改,这样我就可以简单地单击桌面快捷方式来切换鼠标主按钮,而无需传递参数。如果我的方法对其他人有帮助,这是该版本:
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:
您不 为此使用
rundll32
。如果您安装了 .NET Framework 运行时,它会附带多种语言的编译器(例如,v3.5 的
%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe
64 位系统上的 C# 编译器)。您可以用 C# 编写程序:编译方式:
Swap /取消交换按钮:
You do not use
rundll32
for that.If you have the .NET Framework Runtime installed, it comes with compilers for several languages (for example,
%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe
for the v3.5 C# compiler on 64-bit systems). You can write a program in C#:Compile with:
Swap/unswap buttons:
有 hack,可用于为左撇子用户配置鼠标的布局。
只需运行以下命令:
运行此命令可为左撇子用户重新配置鼠标布局。
我将为您解释这种行为:
由 rundll32.exe 调用的函数具有以下函数原型:
SwapMouseButton 具有以下函数原型:
SwapMouseButton 使用与调用的每个函数相同的调用约定 (__stdcall)由 rundll32.exe 执行。
如果您使用带有附加命令行的 rundll32.exe 调用 SwapMouseButton,则该命令行将作为 lpszCmdLine 传递给该函数,并将被忽略。
如果使用 rundll32 调用该函数,rundll32 会自动传递有效的窗口句柄 (HWND) 作为被调用函数的第一个参数。
hwnd - 应该用作所有者窗口的窗口句柄
您的 DLL 创建的任何窗口
rundll32 调用的 SwapMouseButton 函数需要 TRUE 作为第一个参数,以便为惯用左手的用户配置鼠标的布局。当使用 BOOL 值时,rundll32.exe 传递给 user32.dll 内的 SwapMouseButton 的有效窗口句柄不等于 0,并定义为 TRUE。
您可以在此处找到有关 rundll32.exe 以及此可执行文件调用的函数所使用的原型的详细信息:
信息:Windows Rundll 和 Rundll32 接口
您可以找到有关函数 SwapMouseButton 在这里:
SwapMouseButton 函数 (Windows)
There is hack, which can be used to configure the layout of the mouse for a left-handed user.
Just run the following command:
Run this command to reconfigure the layout of the mouse for a left-handed user.
I am going to give you an explanation for this kind of behaviour:
Functions, which are called by rundll32.exe, have the following function prototype:
SwapMouseButton has the following function prototype:
SwapMouseButton uses the same calling convention (__stdcall) as every function called by rundll32.exe does.
If you call SwapMouseButton using rundll32.exe with an additional command-line, this command-line will be passed to this function as lpszCmdLine and will be ignored.
If you call that functions using rundll32, rundll32 automatically passes a valid window handle (HWND) as the first argument of the called function.
hwnd - window handle that should be used as the owner window for
any windows your DLL creates
The function SwapMouseButton function called by rundll32 requires TRUE as the first argument in order to configure the layout of the mouse for a left-handed user. The valid window handle passed by rundll32.exe to SwapMouseButton within user32.dll is unequal to 0 and is defined as TRUE, when using a BOOL value.
You can find details on rundll32.exe and the prototype used by functions called by this executable here:
INFO: Windows Rundll and Rundll32 Interface
You can find details about the function SwapMouseButton here:
SwapMouseButton function (Windows)
C 中的较短交换器:
通过例如安装 Windows SDK 并在 x86_x64 交叉工具命令提示符中编译。
cl swapmbtn.c "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64\user32.lib"
将
main
重命名为WinMain
防止控制台窗口闪烁。A shorter swapper in C:
Install Windows SDK and Compile in x86_x64 Cross Tools Command Prompt via eg.
cl swapmbtn.c "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64\user32.lib"
Rename
main
toWinMain
to prevent the console window flash.下面是一个简单的 C/C++ Windows 应用程序的代码:
编译版本 (x86) 可以在这里找到: http://micromeg.free.fr/english/progs.html
Here is the code for a simple C/C++ Windows application :
Compiled version (x86) can be found here: http://micromeg.free.fr/english/progs.html
我通过在开始菜单中搜索“鼠标”解决了同样的问题。您将找到一个同名的选项。单击它。将出现一个对话框。在“按钮配置”框的按钮选项卡中取消选中“切换主要和辅助按钮”选项。
I solved the same problem by searching "mouse" in the start menu. You will find an option with the same name. click it. A dialog box will appear. There untick the option "switch primary and secondary buttons" in the buttons tab with the "button configurations" box.