Application Class
Many scriptable applications define an
application
class, which is the gem to study if
you want to automate that program. Your quickest route to the
application
class is its description in the
program’s dictionary. We mentioned before that Mac
programs can expose an object model to scripting
components like AppleScript. An object model is a software
abstraction, usually in tree-like form, showing the Apple event
objects and Apple events that you can use with a program.
The application
class is the root or top-level
class in the program’s object model. An Apple-event
object model shows the application
class and all
of its elements and properties (if it has any
defined elements). Figure 1-7 shows a simple object
model for Sherlock 2, the Mac’s fancy Find program.
Sherlock 2 has three properties and contains zero or more
channel
elements. (I am sticking to the strict
definition of an object’s elements, which is that an
object can have zero or more of them. In reality, Sherlock 2 always
has at least one defined channel
, which is the
domain that it is searching.)
channel
elements are themselves objects with their
own properties: “all search sites”
and “name” (e.g., the name of one
channel
is
“Internet”). When in doubt about
how to script a program, always use the program’s
dictionary to examine its application
class. The
elements and properties of the application
class are the things that you will be able to control and derive values from with your AppleScripts. ...
Get AppleScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.