Scripting Date & Time System Prefs

I had this script working for me just fine in Leopard:


tell application "System Preferences"
	activate
	reveal anchor "Clock" of pane "Date & Time"
	tell application "System Events"
		tell application process "System Preferences"
			tell window 1
				tell group 1 of tab group 1
					if value of checkbox "Announce the time:" = 1 then
						click checkbox "Announce the time:"
					end if
				end tell
			end tell
		end tell
	end tell
	quit
end tell

When I upgraded to Snow Leopard, this script failed.

The first thing I learned was that the names of the anchors changed. Instead of “Clock”, it’s now “ClockPref”.

Now I get:


error "System Events got an error: Can't get group 1 of tab group 1 of window 1 of aplication process "System Preferences". Invalid index. number -1719 from group 1 of tab group 1 f window 1 of application process "System Preferences"

Can somebody help?

Model: Intel Mac Mini
Browser: Firefox 3.5.8
Operating System: Mac OS X (10.6)

Hi

Try This:

tell application "System Preferences" to reveal anchor "ClockPref" of pane "com.apple.preference.datetime"
tell application "System Events"
	tell application process "System Preferences"
		tell window 1
			if value of checkbox "Announce the time:" of tab group 1 = 0 then
				click checkbox "Announce the time:" of tab group 1
			end if
		end tell
	end tell
end tell

That works. Thank you very much!