-
-
Save jaredmoody/fad52569fafe5c7d2597edbc18696547 to your computer and use it in GitHub Desktop.
# Don't use this script, use this one instead: | |
# https://gist.github.com/ieatfood/814b065964492f71f728da59a47413bc | |
tell application "System Events" | |
tell process "ControlCenter" | |
set bt to (first menu bar item whose title is "Bluetooth") of menu bar 1 | |
click bt | |
set btCheckbox to checkbox 1 of scroll area 1 of group 1 of window "Control Center" whose title contains "AirPods Pro" | |
set btCheckboxValue to value of btCheckbox | |
tell btCheckbox to click | |
tell bt to click | |
end tell | |
end tell |
Hi @drsnn, I can only guess it's because you don't have the bluetooth icon/menu enabled at the top right of your mac screen. There is probably some way to hide/display it in system preferences.
Thanks for this gem! A tiny little thing, if you are from UK or Australia, then just change Control Center to Control Centre when using this line set btCheckbox to checkbox 1 of scroll area 1 of group 1 of window "Control Center" whose title contains "AirPods Pro"
My pleasure - thanks for the tip!
I found a more elegant script, using IOBluetooth
framework instead of menu clicks, so it should work in other languages or if Apple updates the menus.
https://gist.github.com/ieatfood/814b065964492f71f728da59a47413bc
Yep, that one is better, thanks!
Brilliant! Thanks!
hi !
when i run script, I got
error "System Events got an error: Can’t get menu bar item 1 of menu bar 1 of process \"ControlCenter\" whose title = \"Bluetooth\". Invalid index." number -1719
erorr. Could you help me. Thanks