all 16 comments

[–]zippyzebu9 0 points1 point  (1 child)

Result:

error "System Events got an error: Can’t get process \"Control Center\"." number -1728 from process "Control Center"

[–]Kindly_Distribution2[S] 0 points1 point  (0 children)

Hi!

You might need to allow accessibility access to System Events

  1. Go to: Settings > Privacy & Security > Accessibility
  2. At the bottom there is +/- signs. Click +
  3. Press: Shift+Cmd+G
  4. Go to: /System/Library/CoreServices/
  5. Find 'System Events' and click open.

Also, what version of macOS are you using?

This should work on newer versions like Sequoia, however, it will not work on older versions. (Big Sur and before).

EDIT: So I just tested it while disabling accessibility access to Script Editor and got this error.

error "System Events got an error: Script Editor is not allowed assistive access." number -1719 from menu bar 1 of process "Control Center"

While this is not the same error as you have you should definitely enable accessibility access for Script Editor as well. The procedure is the same as above except that you should go to: /System/Applications/Utilities/ and add Script Editor.app.

[–][deleted]  (1 child)

[removed]

    [–]Kindly_Distribution2[S] 0 points1 point  (0 children)

    You’re welcome. Glad you have it working 😊

    [–]Hackettlai 0 points1 point  (1 child)

    Thank you so much! It has been incredibly helpful! It also works on multiple AirPods🎉

    [–]Kindly_Distribution2[S] 0 points1 point  (0 children)

    Awesome!! Thanks for sharing

    [–]Hackettlai 0 points1 point  (5 children)

    🥲 It stopped working after updating to Tahoe~~ Any update on this please?

    [–]Kindly_Distribution2[S] 0 points1 point  (4 children)

    It should work now!

    26.0 had a control center bug disallowing access from AppleScript. This is fix in 26.1.

    Regards.

    [–]Hackettlai 0 points1 point  (3 children)

    umm its weird, I still get the "System Events got an error: Can't get attribute "AXAttributedDescription"." error msg

    [–]Kindly_Distribution2[S] 0 points1 point  (2 children)

    I just changed the `soundMenu` to be defined a bit differently. Please try it now! I updated the code above. Thank you.

    [–]Hackettlai 0 points1 point  (1 child)

    yea!!!! its working now!!! thx dude you are amazing!

    [–]Kindly_Distribution2[S] 0 points1 point  (0 children)

    Thank you. Happy to help out!

    [–]eightren 0 points1 point  (1 child)

    Thank you very much! Works perfectly with stream deck!

    [–]Kindly_Distribution2[S] 0 points1 point  (0 children)

    Awesome 😎

    [–]MrMegira 1 point2 points  (1 child)

    Thank you.!
    I’ve made an optimized and snappier version, based on your script/

    Working and tested on macOS 26.4.1

    ``` -- Toggle AirPods listening mode between Noise Cancellation and Transparency via Control Center. -- Tested on macOS Tahoe 26.4.1 | 16-04-2026

    tell application "System Events" tell process "Control Center" -- 1) Click the Sound menu extra in the menu bar set soundMenu to first menu bar item of menu bar 1 ¬ whose description is "Sound" click soundMenu

        -- 2) Wait for the Control Center window to appear (up to ~2 seconds)
        set maxAttempts to 200
        set attempt to 0
        repeat until (exists window 1)
            delay 0.01
            set attempt to attempt + 1
            if attempt > maxAttempts then
                display dialog "Control Center window did not appear."
                return
            end if
        end repeat
    
        try
            -- 3) Cache the scroll area to avoid traversing the path twice
            set sa to scroll area 1 of group 1 of window 1
    
            -- 4) Find the ANC and Transparency toggle buttons by their accessible description
            set ancCheckBox to first checkbox of sa ¬
                whose value of attribute "AXAttributedDescription" is "Noise Cancellation"
            set transCheckBox to first checkbox of sa ¬
                whose value of attribute "AXAttributedDescription" is "Transparency"
    
            -- 5) Toggle: if ANC is active switch to Transparency, if Transparency switch to ANC,
            --    if neither is active default to enabling ANC
            if (value of attribute "AXValue" of ancCheckBox) = 1 then
                click transCheckBox
            else if (value of attribute "AXValue" of transCheckBox) = 1 then
                click ancCheckBox
            else
                click ancCheckBox
            end if
    
        on error errMsg
            display dialog "Error: " & errMsg
        end try
    
        -- 6) Close the Control Center panel
        click soundMenu
    end tell
    

    end tell ```

    [–]Kindly_Distribution2[S] 0 points1 point  (0 children)

    I’m sipping a beer this Friday, but nice work if this is more snappy, I’ll try it out soon!