如何使用applescript控制AirPods Pro的噪声消除?

如何使用applescript控制AirPods Pro的噪声消除?,applescript,Applescript,我想实现一个alfred工作流来控制我的AirPods Pro在“透明模式”和“ANC模式”之间切换。我如何编写一个苹果脚本来模拟点击“音频”菜单栏来切换噪声消除。还是有更好的解决方案?我在尝试后找到了一个简单的apple脚本解决方案 tell application "System Events" tell process "SystemUIServer" click (menu bar item 1 of menu bar 1

我想实现一个alfred工作流来控制我的AirPods Pro在“透明模式”和“ANC模式”之间切换。我如何编写一个苹果脚本来模拟点击“音频”菜单栏来切换噪声消除。还是有更好的解决方案?

我在尝试后找到了一个简单的apple脚本解决方案

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        click menu item "your AirPods name" of menu 1 of result
        click menu item "noise control mode" of menu 1 of result
    end tell
end tell
您的AirPods名称
更改为您的AirPods名称,并将
噪音控制模式
更改为您想要更改的模式(如
关闭
噪音消除
,或
透明度
,或将您的语言更改为
关闭
降噪
通透模式中文)


受他的回答启发。我更新了脚本,使其在未连接时自动连接AirPods

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        try
            click menu item "your AirPods name" of menu 1 of result
            click menu item "noise control mode" of menu 1 of result
        on error
            key code 53
            click (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
            click menu item "your AirPods name" of menu 1 of result
            click menu item "Connect" of menu 1 of result
        end try
    end tell
end tell

或者如果您想在
噪音消除
透明度

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        try
            click menu item "your AirPods name" of menu 1 of result
            if value of attribute "AXMenuItemMarkChar" of menu item "Transparency" of menu 1 of result is "✓" then
                click menu item "Noise Cancellation" of menu 1 of result
            else
                click menu item "Transparency" of menu 1 of result
            end if
        on error
            key code 53
            click (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
            click menu item "your AirPods name" of menu 1 of result
            click menu item "Connect" of menu 1 of result
        end try
    end tell
end tell

对于macos Big-Sur(10.14)用户,请使用以下脚本
在尝试之后,我找到了一个简单的apple脚本解决方案

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        click menu item "your AirPods name" of menu 1 of result
        click menu item "noise control mode" of menu 1 of result
    end tell
end tell
您的AirPods名称
更改为您的AirPods名称,并将
噪音控制模式
更改为您想要更改的模式(如
关闭
噪音消除
,或
透明度
,或将您的语言更改为
关闭
降噪
通透模式中文)


受他的回答启发。我更新了脚本,使其在未连接时自动连接AirPods

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        try
            click menu item "your AirPods name" of menu 1 of result
            click menu item "noise control mode" of menu 1 of result
        on error
            key code 53
            click (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
            click menu item "your AirPods name" of menu 1 of result
            click menu item "Connect" of menu 1 of result
        end try
    end tell
end tell

或者如果您想在
噪音消除
透明度

tell application "System Events"
    tell process "SystemUIServer"
        click (menu bar item 1 of menu bar 1 whose description contains "volume")
        try
            click menu item "your AirPods name" of menu 1 of result
            if value of attribute "AXMenuItemMarkChar" of menu item "Transparency" of menu 1 of result is "✓" then
                click menu item "Noise Cancellation" of menu 1 of result
            else
                click menu item "Transparency" of menu 1 of result
            end if
        on error
            key code 53
            click (menu bar item 1 of menu bar 1 whose description contains "bluetooth")
            click menu item "your AirPods name" of menu 1 of result
            click menu item "Connect" of menu 1 of result
        end try
    end tell
end tell

对于macos Big-Sur(10.14)用户,请使用以下脚本
我也遇到了这个问题,所以我用这种方式解决了它(如果AirPods没有连接,则使用错误处理+弹出窗口):


我也遇到了这个问题,所以我用这种方式解决了它(如果AirPods没有连接,则使用错误处理+弹出窗口):