Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CharlieTeach

macrumors newbie
Original poster
Jun 16, 2011
1
0
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.
Code:
 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
	quit
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.
 
Last edited by a moderator:
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 :
http://pfiddlesoft.com/uibrowser/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.