Re: understanding dictionaries
Re: understanding dictionaries
- Subject: Re: understanding dictionaries
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 23 May 2003 22:27:20 -0700
On 5/23/03 9:25 PM, "Monee C. Kidd" <email@hidden> wrote:
>
So I have two questions. First, more specifically, how do I write
>
this specific script for System Preferences? And secondly, can
>
someone point me to some where I can learn to understand the way the
>
dictionaries are set up, so when I read something like:
>
>
Class pane: a preference pane
>
Plural form:
>
panes
>
Properties:
>
<Inheritance> item [r/o] -- All of the properties of the superclass.
That means that it also has the same properties as its superclass - i.e. the
class of which it is a subclass. It's also informing you that the superclass
is 'item'. You have to go look up 'item' as well now. (Only the new Cocoa
apps use this system to any great extent. And some third-party script
editors, like Script Debugger, save you the trouble of looking up the
superclass: they include all superclass properties in the dictionary entry
for the class itself.) 'item' is the most basic class there is, and the only
property it adds is 'class' property. So you can forget about it.
>
name Unicode text [r/o] -- locale independent name of the
>
preference pane; can refer to a pane using the expression: pane
>
"<name>"
Thus is quite helpful. It means you can write scripts that can be used by
people with other languages as their System language, where "Displays" pane
is called something totally different. To find out what this generic 'name'
property of a particular pane might be, open System Prefs to the panel
you're interested in and try running this script:
tell application "System Preferences" to get name of current pane
--> "com.apple.preference.displays"
>
localized name Unicode text [r/o] -- localized name of the
>
preference pane
>
That's "Displays" in your localized English-language system.
>
>
in the dictionary, I know what the heck that means and how I'm
>
supposed to use it? The little blurb about dictionaries in the
>
language guide doesn't explain it at all.
To cut to the point, there's not a great deal you can do with System
Preferences. Most of the new system utilities have barely been scripted.
Considering how crummy the new Cocoa apps which have been more "fully"
scripted have turned out, that's probably a good thing. By the time they get
around to making System preferences more scriptable, maybe they will have
fixed Cocoa application AppleScript, hired some application developers who
know how to script, and enforced more supervision by the AppleScript team.
So there are next to no properties of 'pane' for you to deal with.
You should always look at the 'application' entry (here in Cocoa-land, the
entry in the application's own suite, normally the one in the Standard
Suite) for application-wide properties. And get used to the commands
available in Standard Suite and the proprietary suites too. So
preferences window window [r/o] -- (inherited from the 3application2
class) the main preferences window
current pane pane -- (inherited from the 3application2 class) the
currently selected pane
might both be useful, as well as a number of properties of 'window', such as
'visible'.
You can
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
set visible of preferences window to true
end tell
Try it in Script Editor.
But that's just about all you can do.
If you join the Apple Developers Connection (free) you can download or buy
the Developers Tools, which includes some Pre-Release beta software - a new
version of System Events which allow you to use UI (User Interface )
Scripting - clicking buttons and menu items. It works pretty well in System
Preferences. So with System Events 1.2 beta installed you could:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.displays"
set visible of preferences window to true
end tell
tell application "System Events"
tell process "System Preferences"
select row 4 of table 1 of scroll area 1 of group 1 of tab group 1
of window 1 -- 832 x 624 resolution OMM
end tell
end tell
That just set the resolution on my monitor to 832 x 624.
The beta "System Events" dictionary is enormous and unlike any other. It's
very hard to understand and extremely cryptic where numbers must be used, as
here.. I used a great shareware utility "UI Browser" from Pre-Fab Software
to figure out what controls to call, which made it very simple, and 'select'
from the System Events dictionary.
With normal apps (i.e. Carbon apps derived from some Classic ones where
AppleScript was implemented properly by developers who knew how to do it),
the app's own dictionary would be much fuller and more informative, A few
apps even provide AppleScript documentation.
Or ask here, as you did. All apps are idiosyncratic to some degree or
another, and there are people here who have scripting experience in any app
you can come up with (as long as it's scriptable).
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.