如何使用AppleScript控制AirPods Pro的消噪? [英] How to use applescript to control the noise canceling of AirPods Pro?

查看:13
本文介绍了如何使用AppleScript控制AirPods Pro的消噪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

推荐答案

尝试后发现了一个简单的Apple Script解决方案。

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

your AirPods name更改为您的AirPods名称,并将您要更改的noise control mode更改为(如OffNoise CancellationTransparency,或更改为您的中文语言为关闭降噪通透模式)。


anton-uspehov的回答启发。我更新了脚本,以便在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

或者如果要在Noise CancellationTransparency之间自动切换

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)用户,请使用以下脚本

set AirPodsName to "Your AirPods name"
tell application "System Events"
    tell application process "ControlCenter"
        set volMenu to menu bar item "volume" of menu bar 1
        tell volMenu to click
        set btCheckbox to checkbox 1 of scroll area 1 of group 1 of window "ControlCenter" whose title contains AirPodsName
        set btCheckboxValue to value of btCheckbox
        tell btCheckbox to click
        delay 0.1
        set checkbox_anc to checkbox 1 of scroll area 1 of group 1 of window "ControlCenter" whose title contains "Noise Cancellation"
        if exists checkbox_anc then
            if value of checkbox_anc is 1 then
                set checkbox_transparent to checkbox 1 of scroll area 1 of group 1 of window "ControlCenter" whose title contains "Transparency"
                tell checkbox_transparent to click
            else
                tell checkbox_anc to click
            end if
        end if
        tell volMenu to click
    end tell
end tell

这篇关于如何使用AppleScript控制AirPods Pro的消噪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆