Please, Can Someone Help Me Tweak A Systems Pref Script?

I’m green at Applescript (at best). I wrote a script that opens System Preferences and then, with a second run of the same script, opens “Mission Control” on Yosemite. Both runs of the script produce an error dialogue box, “Can’t get menu item “View” of menu bar 1 of process System Preferences…”

But it does it what I want it to do: It opens Mission Control.

My goal is to display Mission Control to the user - with one run of the script - and then request the that user choose “As Space” in Dashboard (for this request, I can merely write a dialog box - so, no worries there). If the user doesn’t choose “as space,” then the script aborts. Another way to go: If the user chooses “as overlay” (in Dashboard) the script aborts (either “off” or “as space” - in Dashboard - works for me).

Is that possible? I’d be really grateful for any help…thank you in advance.

tell application “System Preferences”
activate
end tell

tell application “System Events”
tell process “System Preferences”
click menu item “Mission Control” of menu “View” of menu bar 1
delay 2
tell window “Mission Control”
click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
delay 1
delay 1
end tell
end tell
end tell

You may use this code to open the wanted pane :

tell application "System Preferences"
	activate
	reveal pane ("Mission" & linefeed & "Control") # Yes, there is a linefeed in the name !
end tell

Yvan KOENIG running El Capitan 10.11.1 in French (VALLAURIS, France) dimanche 1 novembre 2015 19:15:30