Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 01-05-2011, 03:32 PM   #1
NewEvolution
Prospect
 
Join Date: Jan 2011
Posts: 12
Question Navigating System Preferences Preference Panes with AppleScript

Hey all:

I'm trying change some settings in the Keyboard pane of System Preferences, and I haven't the foggiest idea how to format the syntax to do so.

regulus6633's reply to another topic on here showing how to disable tap-to-click was super useful for part of my script, as I was able to modify that snippet to disable two-finger scroll quite easily by just changing the name of the checkbox being clicked:
Code:
tell application "System Preferences"
	reveal (pane id "com.apple.preference.trackpad")
end tell
tell application "System Events"
	tell process "System Preferences"
		tell checkbox "Scroll" of group 1 of window 1
			repeat until exists
				delay 0.2
			end repeat
			if value is true then click
		end tell
	end tell
end tell
Ideally what I want to know is how I can find the names/ids/whatevers of the various sections/items/checkboxes/etc. that show up in a particular Preference Pane. As a snippet, right now I have:
Code:
tell application "System Preferences"
	reveal (pane id "com.apple.preference.keyboard")
end tell
tell application "System Events"
	tell process "System Preferences"
		????
	end tell
end tell
I haven't the foggiest idea what to put where those ????s now sit. Reading regulus6633's code, it's easy to understand how checkbox "Scroll" of group 1 of window 1 works, but I haven't a clue how he knew that "Scroll" was in group 1 or knew that that group's index was 1 or anything of the sort. If there's some online reference to how Apple goes about naming the sections of the Preference Panes windows I haven't been able to Google it up.

Ideally I'd like that sort of reference, as then I'd be able to puzzle this out, and solve similar problems in the future. If not, I can post exactly what I'm attempting to do in more detail (with screenshots if necessary) and hope someone here can script up a solution that I can then shamelessly reverse-engineer.

Thanks!
NewEvolution is offline   Reply With Quote
Old 01-06-2011, 09:56 AM   #2
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 4,262
UIElementInspector. Apple releases it as demonstration source code, but there's a compiled binary included in the download. it will show you the UI element hierarchy for anything you hover the mouse over. it's not a super intuitive tool, but you'll get the hang of it. just remember that cmd-F7 freezes the inspector on a particular element, and then you can play with the buttons/menus to see what you can discover.

(P.s. - it's a modal floating pane, without menus, and that never catches keyboard input - the only way to make it go away is to click the close box for the pane.)
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 01-06-2011, 04:25 PM   #3
NewEvolution
Prospect
 
Join Date: Jan 2011
Posts: 12
Quote:
Originally Posted by tw
UIElementInspector. etc.


Thanks tw!

I actually found that yesterday after following a link on here to macscripter.net to check it out. I couldn't reply to this thread to say so though, since I was still on probation and thus the thread hadn't actually appeared.

UIElementInspector's output is definitely interesting but I was able to figure it out and get AppleScript to select & modify the elements of the preference pane that I wanted. Definitely makes AppleScript far more versatile now that I know I can script anything that deals with UI elements.
NewEvolution is offline   Reply With Quote
Reply

Tags
applescript, automation, navigation, preference panes, system preferences

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.