System Preferences - Turning off Dashboard

I’m trying to uncheck the Dashboard checkbox in the Keyboard & Mouse pane of System Preferences but am having no luck. Here’s my script, glued together from some other posts on here:



tell application "System Preferences"
	activate
	set the current pane to pane id "com.apple.preference.keyboard"
	reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
	tell application "System Events"
		tell process "System Preferences"
			set value of attribute "AXFocused" of text field 2 of row 1 of outline 1 of scroll area 1 of tab group 1 of window 1 to true
			set value of checkbox 1 of row 1 of outline 1 of scroll area 1 of tab group 1 of window 1 to 1
		end tell
	end tell
end tell

I don’t get an error but I also don’t get any results. What am I missing? Thanks.

Hi,

if you’re running Leopard, there is an easier (and more reliable) way


tell application "System Events"
	tell expose preferences to tell dashboard shortcut
		set function key modifiers to {}
		set function key to none
	end tell
end tell

Unfortunately most of the clients using this will not be on Leopard…but I put that tip in my subroutines as a nice one, thanks. Any help for older OS’s?

the value of the checkbox is not settable via the attribute,
so try this, I hope it works also in Tiger


tell application "System Preferences"
	activate
	reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
end tell
tell application "System Events"
	tell process "System Preferences"
		tell outline 1 of scroll area 1 of tab group 1 of window "Keyboard & Mouse"
			tell (1st row whose value of text field 1 is "Dashboard")
				if value of checkbox 1 is 1 then click checkbox 1
			end tell
		end tell
	end tell
end tell

Actually I found an easier way:



tell application "System Preferences"
	activate
	set the current pane to pane id "com.apple.preference.expose"
	reveal anchor "Main" of pane id "com.apple.preference.expose"
	tell application "System Events"
		tell process "System Preferences"
			tell group 2 of tab group 1 of window 1
				click pop up button 4
				click menu item "-" of menu 1 of pop up button 4
			end tell
		end tell
	end tell
end tell


Thanks for the help.