TJR*_*TJR 6 windows mouse rundll32
我正在重复另一个论坛的问题,因为我想要同样的答案.
来自MSDN的SwapMouseButton函数.
如何通过rundll32.exe将布尔数据从命令提示符传递到从user32.dll运行的命令中的布尔类型参数?
我正试图从CMD(命令提示符)运行它
Run Code Online (Sandbox Code Playgroud)RUNDLL32.EXE user32.dll,SwapMouseButton *
星号在这里的地方是争论应该去的地方.我已经运行它没有参数,它交换了我的左右鼠标按钮(似乎TRUE是布尔参数的默认条目).现在我要撤消它.但是我已经尝试了每一个在参数中传递FALSE,并且没有一个工作(没有设置我的鼠标按钮恢复正常).
- F
- F
- 假
- 假
- 假
- "假"
- "假"
- "假"
- 0
- -1
请帮我根据需要传递论据.提前致谢.
小智 15
非常感谢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
}
}
}
Run Code Online (Sandbox Code Playgroud)
gra*_*ity 13
Q164787:信息:Windows Rundll和Rundll32接口
[...] Rundll和Rundll32程序不允许您从任何DLL调用任何导出的函数.例如,您不能使用这些实用程序来调用从系统DLL导出的Win32 API(应用程序编程接口)调用.这些程序只允许您从DLL中调用函数,这些函数是由它们显式编写的.
如果安装了.NET Framework Runtime,它会附带多种语言的编译器(例如,%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc.exe
64位系统上的v3.5 C#编译器).你可以用C#编写一个程序:
using System.Runtime.InteropServices;
using System;
class SwapMouse {
[DllImport("user32.dll")]
public static extern Int32 SwapMouseButton(Int32 bSwap);
static void Main(string[] args) {
if (args.Length > 0 && String.Compare(args[0], "/u", true) == 0)
SwapMouseButton(0);
else
SwapMouseButton(1);
}
}
Run Code Online (Sandbox Code Playgroud)
编译:
"%SystemRoot%\Microsoft.NET\Framework64\v3.5\csc" swap.cs
Run Code Online (Sandbox Code Playgroud)
交换/取消交换按钮:
swap
swap /u
Run Code Online (Sandbox Code Playgroud)
有 hack,可用于为惯用左手的用户配置鼠标的布局。只需运行以下命令:
rundll32.exe user32.dll,SwapMouseButton
Run Code Online (Sandbox Code Playgroud)
运行此命令可为惯用左手的用户重新配置鼠标布局。
我将为您解释这种行为:
由 rundll32.exe 调用的函数具有以下函数原型:
void CALLBACK EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
Run Code Online (Sandbox Code Playgroud)
SwapMouseButton 有如下函数原型:
BOOL WINAPI SwapMouseButton(
_In_ BOOL fSwap
)
Run Code Online (Sandbox Code Playgroud)
SwapMouseButton 使用与 rundll32.exe 调用的每个函数相同的调用约定 (__stdcall)。
如果您使用带有附加命令行的 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)