Alright, I think I am close to getting this working. I am trying to toggle Bluetooth via GUI scripting in System Preferences.
The problems I am getting, is that it does not activate Bluetooth. And it errors on the Turn Off click command. Please help!
tell application "System Preferences"
activate
set current pane to pane "com.apple.preferences.Bluetooth"
tell application "System Events" to tell window "Bluetooth" of process "System Preferences"
click radio button "Settings" of tab group 1
if exists button "Turn Bluetooth On" then
tell button "Turn Bluetooth On"
click
end tell
else
tell button "Turn Bluetooth Off"
click
end tell
end if
end tell
end tell
quit application "System Preferences"
The problems I am getting, is that it does not activate Bluetooth. And it errors on the Turn Off click command. Please help!