Re: understanding dictionaries
Re: understanding dictionaries
- Subject: Re: understanding dictionaries
- From: julifos <email@hidden>
- Date: Sat, 24 May 2003 11:28:55 +0200
>
OK, maybe I'm just not getting this language. I'm reading through the
>
Language Guide and I'm understanding the syntax of how the various
>
examples are put together. But what I'm still missing is how to make
>
this knowledge more general. When I look in the dictionaries for
>
various applications, I have no idea how to construct a sentence that
>
will do what I want it to do. For example, right now, I want to write
>
a script that will open the Displays panel in System Preferences and
>
reset the monitor brightness to full. I wrote a "script" in what I
>
thought was English language syntax, but Applescript recognizes none
>
of it.
Most of times AppleScript's syntax is very severe, though its apparent
flexibility...
>
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:
Unfortunatelly, System Preferences (I think) is the baddest app to start
scripting, since it is not very scriptable... This is my greatest
achievement using its dictionary:
##############################
tell application "System Preferences"
set current pane to pane "com.apple.preference.dock"
end tell
##############################
If you wish also check checkboxes, setup sliders and choose menu items from
popup buttons, you must do it through GUI Scripting...
More info: <
http://www.apple.com/applescript/GUI/>
There and here below, you can find several examples of GUI scripting using
the latest beta of "System Events":
<
http://search.lists.apple.com/applescript-users?q=system+events+preferences
&m=all&o=0&wf=200010&wm=sub&ps=10>
>
Class pane: a preference pane
>
Plural form:
>
panes
>
Properties:
>
<Inheritance> item [r/o] -- All of the properties of the superclass.
>
name Unicode text [r/o] -- locale independent name of the
>
preference pane; can refer to a pane using the expression: pane
>
"<name>"
>
localized name Unicode text [r/o] -- localized name of the
>
preference pane
>
>
>
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.
About the dictionaries comprehension, this is a quick process (not the final
syntax, some times). Eg:
_____________________
Class pane: a preference pane
Plural form
Panes
_____________________
= A pane is an object under the hierarchy of System Preferences app.
_____________________
Properties
<Inheritance> item [r/o] -- All of the properties of the superclass.
_____________________
= This is a technicism that doesn't work. AppleScript defines a number of
standard events in a suite (its core suite or "standard" suite, some time
mixed, some times absolutelly useless). Eg: save, exists, etc. But these
(depending on the app) are useless (Why do you need "open"?) You will find a
number of apps which are "scriptable" (they have a dictionary), but are NOT
scriptable.
"item" is one of these useless defined classes.
_____________________
name Unicode text [r/o] -- locale independent...
_____________________
This is useful! The property "name" of the object "pane". See this:
############
tell application "System Preferences"
name of pane 1
end tell
--> "com.apple.preference.universalaccess"
############
So, "name" is a property which will be returned as Unicode text (when
prompted for it) and is read/only ([r/o]). You can ask for it, but not set
it.
If you take a look to "application"'s class (next to "pane"), you will see a
property read/writable: "current pane"
############
tell application "System Preferences"
current pane
end tell
############
This will return nothing (if there is not a preference pane opened) or a
reference to the current opened pane. Eg:
--> pane 12 of application "System Preferences"
And, since this property is "writable", you can access it (see first
sample):
##############################
tell application "System Preferences"
set current pane to pane "com.apple.preference.dock"
end tell
##############################
As you see, you can access an object using one of its properties (name) or
one of its should-be-defined-properties (index):
##############################
tell application "System Preferences"
set current pane to pane 5
end tell
##############################
For better understanding of dictionaries, I would start with a better
defined and strong dictionary, such as the one of Standard Additions, Finder
or Internet Explorer.
Cheers!
JJ
_______________________________________________
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.