Skip to content

Instantly share code, notes, and snippets.

@kevin-funderburg
Created May 15, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin-funderburg/e980d63f4f16c91e2c50e710aed1fec3 to your computer and use it in GitHub Desktop.
Save kevin-funderburg/e980d63f4f16c91e2c50e710aed1fec3 to your computer and use it in GitHub Desktop.
Toggle bluetooth on and off.
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
tell menu of bt
if exists menu item "Turn Bluetooth On" then
click menu item "Turn Bluetooth On"
else if menu item "Turn Bluetooth Off" exists then
click menu item "Turn Bluetooth Off"
else
key code 53 --escape
end if
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment