GUI Scripting Preferences

I’ve just started playing with the GUI Scripting and it seems to be going well, but I seem to be missing out on how to click certain radio buttons. To be specific, in the Appearance Preference Pane I want the radio button for “Together” to be clicked, but I can’t figure out the syntax for that action. I am using the UI Element Inspector, but I guess its not telling me everything I need to know. Attached is what I have so far, and it works fine up to the point of the Click, what am I doing wrong.

A secondary question is, can you recommend any good online resources (besides apples lame little into) on how to do GUI scripting? Thanks!!


tell application "System Preferences"
	activate
end tell

--Open Appearance

tell application "System Events"
	tell process "System Preferences"
		click menu item "Appearance" of menu "View" of menu bar 1
		click radio button "Together" of radio group 1 of window "Appearance"
	end tell
end tell

Thanks in advance!
–PEACE–

Why do I post these things when I know that I will eventually answer my own question anyway. :rolleyes:
Anyway, I just want to say to Apple “HEY A LITTLE MORE DOCUMENTATION WOULDN’T KILL YA” and to present an actual working script to ya… The key to figuring it out was to ‘Lock On’ to the button which brought up the Locked on window in UI Element Inspector… from the Locked on window, click on the Hightlight check box and then use the ‘goto’ menu to try to figure out which item is which… for example, in the provided script you will see that I had it use Radio Group 2… the inspector does not tell you that it is Radio Group 2 directly, you have to do a little detective work… Clicking that got popup, choose AXParant until you get the whole System Preferences window highlighted… then click the got menu again and you should see AXChildren with a sub menu… Looking at that submenu (in Appearances anyway) you can see 2 instances of Radio Group… Click on one of the radio groups from that menu and it will hilight, if you got the wrong one, go back to the AXParent and choose the next possible item until you have what you want selected… once you figure out which is which, use that goto menu again and count, from the top of the list, down until you get to the correct item, only counting occurances of the items that you are trying to pinpoint (in this case Radio Groups). The group I wanted was the second Radio Group in the list, and thus that is the number used in the script. If I rambled on too much, I applologise :stuck_out_tongue:


tell application "System Preferences"
	activate
end tell

--Open Appearance

tell application "System Events"
	tell process "System Preferences"
		click menu item "Appearance" of menu "View" of menu bar 1
		click radio button "Together" of radio group 2 of window "Appearance"
		click pop up button 6 of window "Appearance"
		click menu item 3 of menu 1 of pop up button 6 of window "Appearance"
	end tell
end tell

Anyway, I hope this helps someone.

–PEACE–

PreFab Software’s UI Browser will make your life a ton easier.

To open the “Appearance” System Prefs pane directly, code

tell app "System Preferences" to set current pane to pane "com.apple.preference.general"

To see all of the proper names of the System Preferences panes, code

tell app "System Preferences" to get every pane

Note that some use the string “.preferences.” and others use the string “.preference.”.

You’re right that it’s crazy that Apple does not explicitly document these things that they spend so much time coding. It doesn’t make any sense.

Thanks to Bill Cheeseman for this tip.

Well I unfortunately work in a corp environment and even spending the $55 for UI Broswer requires hours of negotiations and tons of paperwork, which is why I rely on kind folks like you… I use the Menu seclection for system preferences simply because it is easy to look at the menu and not have to worry about the exact name of a particular com.whater.plist, just have the script pick the real-world name out of the menu and be done with it. Thanks for the tip!

–PEACE–

johnnylundy wrote:

Not to quibble, but UI Browser is a product of PreFab Software. Bill Cheeseman is heavily involved. :wink:

Thanks for pointing out my goof. Corrected now.