【问题标题】:Control of mouse settings from command line in Windows 7在 Windows 7 中从命令行控制鼠标设置
【发布时间】:2020-01-16 20:42:07
【问题描述】:

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

【问题讨论】:

    标签: windows mouse


    【解决方案1】:

    您可以将代码复制到 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))
    

    【讨论】:

    猜你喜欢
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-15
    • 2011-11-15
    • 2011-02-12
    • 2013-11-29
    • 1970-01-01
    相关资源
    最近更新 更多