从 Windows 7 中的命令行控制鼠标设置



由于残疾,我喜欢能够从使用右手鼠标切换到左手鼠标,然后再切换回来,每半小时左右一次。从控制面板执行此操作比我想要的要慢。虽然我可以在命令行或.bat文件中使用main.cpl打开鼠标设置控制器,但我希望能够使用批处理文件进行整个左右切换。这是否可能,如果可能,如何?

您可以将代码复制到 PS1 文件并使用 Powershell 运行它:

[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$SwapButtons = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool SwapMouseButton(bool swap);
'@ -Name "NativeMethods" -Namespace "PInvoke" -PassThru
[bool]$returnValue = $SwapButtons::SwapMouseButton(!([System.Windows.Forms.SystemInformation]::MouseButtonsSwapped))

最新更新