View Full Version : Apple script to click button in popup menu?

May 17, 2012, 07:48 AM
Hi everyone,
I'm new to applescript but I've managed to cobble together a application to turn off bluetooth. I'm a teacher and work in a computer lab with bluetooth keyboards and would find it useful to cut off access to computers from time to time. Here's what I've got so far.

tell application "System Preferences"
set current pane to pane "com.apple.preferences.Bluetooth"
tell application "System Events"
tell process "System Preferences"
set isOnCheckbox to checkbox "On" of window "Bluetooth"
if value of isOnCheckbox is 1 then
click isOnCheckbox
end if
end tell
end tell
end tell

This turns off their bluetooth but i get a popup menu asking if I really want to turn off the bluetooth.
The Question is: How do i add to this script to make it accept the changes?

Thanks for your help.

May 17, 2012, 10:00 AM
Take a look at the Accessibility Inspector for how to click the button in the popup menu. That's what it is called on Leopard. Don't know what it is in SL or Lion. You'll find it by installing Xcode. Or you can use UI Browser found here :