This AppleScript will turn on Noise Cancellation if the AirPods are already connected:
tell application "System Events"
tell application process "ControlCenter"
try
click menu bar item "Sound" of menu bar 1
tell window 1
UI elements
tell scroll area 1
click (first checkbox whose title contains "Cancellation")
end tell
end tell
end try
end tell
end tell
Thanks, Jim.
It works when I'm not in the full screen video mode. When I'm in the full screen video mode, it only shows the menu (the first click), but does not execute the 2nd click.
If there is a way to make the Shortcuts to work, it would be great, as it does it in the background.