Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
AppleScript: The Definitive Guide, 2nd Edition
Preface
The Scope of This Book
Versions
How This Book Is Organized
Part I, AppleScript Overview
Part II, The AppleScript Language
Part III, AppleScript in Action
Part IV, Appendixes
Conventions Used in This Book
How to Contact Us
Safari® Enabled
Acknowledgments (First Edition)
Acknowledgments (Second Edition)
I. AppleScript Overview
1. Why to Use AppleScript
1.1. The Nature and Purpose of AppleScript
1.2. Is This Application Scriptable?
1.3. Calculation and Repetition
1.4. Reduction
1.5. Customization
1.6. Combining Specialties
2. Where to Use AppleScript
2.1. Script Editor
2.1.1. Apple's Script Editor
2.1.2. Smile
2.1.3. Script Debugger
2.2. Internally Scriptable Application
2.3. Script Runner
2.4. Automatic Location
2.5. Application
2.5.1. Applet
2.5.2. AppleScript Studio
2.5.3. Cocoa
2.6. Unix
2.7. Hyperlinks
2.8. Automator
3. Basic Concepts
3.1. Apple Events
3.1.1. Reply
3.1.2. Scriptability
3.1.3. The Life of an Apple Event
3.1.4. What an Apple Event Looks Like
3.1.5. Go and Catch an Apple Event
3.1.6. What All This Has to Do with AppleScript
3.2. The Open Scripting Architecture
3.2.1. Components
3.2.2. Other Scripting Languages
3.2.3. Talking to a Scripting Component
3.2.4. Maintenance of State
3.3. Script
3.3.1. Script as Drive
3.3.2. Script as Program
3.3.3. Script as Script Object
3.3.4. Script as Scripting Component Operand
3.3.5. Script as File
3.4. Compiling and Decompiling
3.4.1. Compiling
3.4.2. Decompiling
3.5. Compiled Script Files
3.5.1. Compiled Script File Formats
3.5.2. Run-only Scripts
3.6. Script Text File
3.7. Applet and Droplet
3.8. Scripting Addition
3.9. Dictionary
3.9.1. Dictionary Formats
3.9.2. Dictionary Troubles
3.10. Missing External Referents
3.10.1. Application Missing at Compile Time
3.10.2. Application Missing at Decompile Time
3.10.3. Application Missing When a Compiled Script Runs
3.10.4. Application Missing When an Applet Launches
3.10.5. Scripting Addition Missing
3.11. Modes of Scriptability
3.11.1. Recordability
3.11.2. Attachability
II. The AppleScript Language
4. Introducing the Language
4.1. A Little Language
4.2. Extensibility and Its Perils
4.3. The "English-likeness" Monster
4.4. Object-likeness
4.5. LISP-likeness
4.6. The Learning Curve
5. Syntactic Ground of Being
5.1. Lines
5.1.1. Line-Break Characters
5.1.2. Line-Break Characters in Strings
5.1.3. Continuation Character
5.2. Result
5.2.1. Explicit Result
5.2.2. Implicit Result
5.3. Comments
5.4. Abbreviations and Synonyms
5.5. Blocks
5.6. The
6. A Map of the World
6.1. Scope Blocks
6.2. Levels and Nesting
6.3. The Top Level
6.4. Code and the Run Handler
6.5. Variables
7. Variables
7.2. Assignment and Retrieval
Reference Section
set
Reference Section
copy
7.2.1. Set by Reference
7.2.2. Multiple Assignment
7.2.3. Retrieval
7.3. Declaration and Definition of Variables
7.3.1. Definition
7.3.2. Initialization
7.3.3. Typing
7.4. Variable Names
7.4.1. Case-Insensitivity of Variable Names
7.4.2. Memory of Variable Names
7.4.3. Variable Names and Vertical Bars
8. Script Objects
8.1. Script Object Definition
8.2. Run Handler
8.3. Script Properties
8.4. Script Objects as Values
8.5. Top-Level Entities
8.5.1. Accessing Top-Level Entities
8.5.2. Persistence of Top-Level Entities
8.5.2.1. What reinitializes top-level entities
8.5.2.2. File-level persistence
8.6. Compiled Script Files as Script Objects
Reference Section
load script
Reference Section
run script
Reference Section
store script
8.6.1. Data Storage
8.6.2. Library
8.7. Inheritance
8.7.1. Polymorphism
8.7.2. Continue
8.7.3. The Implicit Parent Chain
8.7.4. Non-Script Parent
8.7.5. Handler Calls, Commands, and Script Objects
9. Handlers
9.1. Handler Definition
9.2. Returned Value
9.3. Handlers as Values
9.4. Parameters
9.5. Pass by Reference
9.6. Syntax of Defining and Calling a Handler
9.6.1. Optional Parameters
9.6.2. No Parameters
9.6.3. Positional Parameters
9.6.4. Prepositional Parameters
9.6.5. Named Parameters
9.7. Event Handlers
9.8. The Run Handler
9.9. Recursion
9.10. Power Handler Tricks
9.10.1. Handler and Script Object as Parameter
9.10.2. Handler and Script Object as Result
10. Scope
10.1. Regions of Scope
10.2. Kinds of Variable
10.3. Scope of Top-Level Entities
10.4. Scope of Locals
10.5. Scope of Globals
10.5.1. Global Declarations: The Downward Effect
10.5.2. Global Declarations: The Upward Effect
10.5.2.1. Global as static
10.5.2.2. Global as script property
10.5.2.3. The double effect of global declarations
10.6. Scope of Undeclared Variables
10.7. Declare Your Variables
10.8. Free Variables
10.9. Redeclaration of Variables
10.10. Closures
10.10.1. Closures and Handlers
10.10.2. Closures and Stored Script Objects
11. Objects
11.1. Messages
11.2. Attributes
11.3. Class
11.4. Target
11.4.1. Direct Object
11.4.2. Tell Block
11.4.3. Of
11.4.4. The Chain of Ofs and Tells
11.4.5. Terms in Scope
11.4.6. Nested Targets
11.5. Get
11.6. It
11.7. Me
11.8. Properties and Elements
11.9. Element Specifiers
11.9.1. Name
11.9.2. Index
11.9.3. ID
11.9.4. Some
11.9.5. Every
11.9.6. Range
11.9.7. Relative
11.9.8. Boolean Test
11.10. Operations on Multiple References
11.11. Assignment of Multiple Attributes
11.12. Object String Specifier
12. References
12.1. Reference as Target
12.2. Reference as Incantation
12.2.1. Preresolution of Terminology
12.2.2. Being Careful with References
12.3. Creating a Reference
12.4. Identifying References
12.5. Dereferencing a Reference
12.6. Trouble with Contents
12.7. Creating References to Variables
12.8. Reference as Parameter
13. Datatypes
13.1. Application
13.2. Machine
13.3. Data
13.4. Boolean
13.5. Integer, Real, and Number
13.6. Date
13.6.1. Date Properties
13.7. String
13.7.1. String Properties
13.7.2. String Elements
13.8. Unicode Text
13.8.1. Forming Unicode Text
13.8.2. Other Text Classes
13.9. File and Alias
13.9.1. Alias
13.9.2. Other File Classes
13.9.3. File Properties
13.9.4. File Classes in Applications
13.10. List
13.10.1. List Recursion
13.10.2. Secondary List Classes
13.10.3. List Properties
13.10.4. List Elements
13.11. Record
13.11.1. Record Properties
14. Coercions
14.1. Implicit Coercion
14.2. Explicit Coercion
Reference Section
as
Reference Section
get... as
14.2.1. Coercion by AppleScript
14.2.2. Coercion by a Scriptable Application
14.3. Boolean Coercions
14.4. Number, String, and Date Coercions
14.5. File Coercions
14.6. List Coercions
14.7. Unit Conversions
15. Operators
15.1. Implicit Coercion
15.2. Arithmetic Operators
+
-
*
/
div
mod
^
15.3. Boolean Operators
and
or
not
15.4. Comparison Operators
= (is)
≠ (is not)
<
>
≤
≥
15.5. Containment Operators
contains, does not contain, is in, is not in
begins with
ends with
15.6. Concatenation Operator
&
15.7. Parentheses
15.8. Who Performs an Operation
15.8.1. Direct Operations
15.8.2. Boolean Test Element Specifiers
16. Global Properties
16.1. Strings
return
tab
quote
space
text item delimiters
16.2. Numbers
pi
minutes
hours
days
weeks
16.3. Miscellaneous
version
17. Constants
true , false
yes, no, ask
missing value
null
plain, bold, italic, outline, shadow, underline, superscript, subscript, strikethrough, small caps, all caps, all lowercase, condensed, expanded, hidden
case, diacriticals, white space, hyphens, expansion, punctuation, numeric strings
application responses
current application
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
January, February, March, April, May, June, July, August, September, October, November, December
18. Commands
18.1. Application Commands
launch
activate
reopen
quit
18.2. Standard Commands
count
18.3. Logging Commands
log
stop log, start log
19. Control
19.1. Branching
19.2. Looping
19.2.1. Repeat Forever
19.2.2. Repeat N Times
19.2.3. Repeat While
19.2.4. Repeat Until
19.2.5. Repeat With
19.2.6. Repeat With... In
19.3. Tell
19.4. Using Terms From
19.5. With
19.5.1. Timeout
19.5.2. Transaction
19.6. Considering/Ignoring
19.6.1. Ignoring Application Responses
19.6.2. String Considerations
19.7. Errors
19.7.1. Throwing an Error
19.7.2. Catching an Error
19.8. Second-Level Evaluation
III. AppleScript In Action
20. Dictionaries
20.1. Resolution of Terminology
20.1.1. Loading the Dictionary
20.1.2. Translating the Terms
20.1.2.1. The innermost application dictionary
20.1.2.2. Hunting for each term
20.2. Terminology Clash
20.2.1. Compile-time Error
20.2.2. Runtime Error
20.2.3. No Error, Surprising Behavior
20.2.4. Detecting Terminology Clash
20.2.5. No Terminology Clash
20.2.6. Resolving Terminology Clash
20.2.7. Clash Between Dictionaries
20.3. Nonsensical Apple Events
20.4. Raw Four-Letter Codes
20.5. Multiple-Word Terms
20.6. What's in a Dictionary
20.6.1. Value Types
20.6.2. Enumerations
20.6.3. Classes
20.6.3.1. Plurals
20.6.3.2. Class inheritance
20.6.4. Properties and Elements
20.6.5. Records
20.6.6. Events
20.6.7. Suites
20.7. The 'aeut ' Resource
20.8. Inadequacies of the Dictionary
20.8.1. Defects in the Object Model
20.8.2. Defective Element Specifiers
20.8.3. Properties with Eponymous Classes
20.8.4. Clashes with AppleScript
20.8.5. Wrong Value Types
20.8.6. Wrong Parameter Details
20.8.7. Make
20.8.8. Selection
20.8.9. Idioms for Common Tasks
20.8.10. Events and Classes
20.8.11. Coercions
20.8.12. Bad Grammar
20.8.13. Multiple Listings
20.8.14. Busted Scriptability
20.8.15. Bad Comments
21. Scripting Additions
21.1. Pros and Cons of Scripting Additions
21.2. Classic Scripting Additions
21.3. Loading Scripting Additions
21.4. Standard Scripting Addition Commands
21.4.1. Dialogs
display dialog
display alert
choose from list
choose file
choose folder
choose file name
choose application
choose URL
choose remote application
choose color
21.4.2. Noises
beep
get volume settings
set volume
say
21.4.3. File and Machine Information
system info
system attribute
path to
path to
path to resource
list disks
list folder
info for
21.4.4. File Data
open for access
read
write
get eof
set eof
close access
21.4.5. String and Clipboard
ASCII character
ASCII number
offset
summarize
set the clipboard to
clipboard info
the clipboard
21.4.6. Numbers and Dates
round
random number
current date
time to GMT
21.4.7. Miscellaneous
delay
mount volume
scripting components
open location
22. Speed
22.1. Tools of the Trade
22.2. Apple Events
22.3. List Access
22.4. Scripting Additions
22.5. Context
23. Scriptable Applications
23.1. Targeting Scriptable Applications
23.1.1. Local Applications
23.1.2. Remote Applications
23.1.3. XML-RPC and SOAP
23.2. Some Scriptable Applications
23.2.1. iApps and Utilities
23.2.2. Finder
23.2.3. System Events
23.2.4. SpeechRecognitionServer
23.2.5. URL Access Scripting
23.2.6. Keychain Scripting
23.2.7. Image Events
23.2.8. Database Events
24. Unscriptable Applications
24.1. Historical Perspective
24.2. Getting Started with Accessibility
24.3. GUI Scripting Examples
25. Unix
25.1. Do Shell Script
25.2. Osascript
26. Triggering Scripts Automatically
26.1. Digital Hub Scripting
26.2. Folder Actions
26.3. CGI Application
26.4. Timers, Hooks, Attachability, Observability
27. Writing Applications
27.1. Applets
27.1.1. Applet Options
27.1.2. Editing an Applet
27.1.3. Applet Event Handlers
27.1.4. Droplets
27.1.5. Persistence
27.1.6. Applet Scriptability
27.2. AppleScript Studio
27.2.1. Cocoa and AppleScript Studio
27.2.2. The Pieces of AppleScript Studio
27.2.3. AppleScript Studio Example
27.2.4. Automator Actions
27.3. Cocoa Scripting
27.4. AppleScript Studio Scriptability
IV. Appendixes
A. The AppleScript Experience
A.1. The Problem
A.2. A Day in the Life
A.2.1. Caught in the Web of Words
A.2.2. One for All and All for One
A.2.3. Seek and Ye Shall Find
A.2.4. Turning the Tables
A.2.5. Refiner's Fire
A.2.6. Naming of Parts
A.2.7. Practice Makes Perfect
A.2.8. Finder's Keepers
A.2.9. I've Got a Little List
A.3. Conclusions, Lessons, and Advice
B. Apple Events Without AppleScript
B.1. Pure Raw Apple Events
B.2. JavaScript
B.3. UserTalk
B.4. Perl
B.5. Python
C. Tools and Resources
C.1. Scripting Software and Tools
C.2. Scriptable Software
C.3. AppleScript Documentation
C.4. Writing a Scripting Addition
C.5. Writing a Scriptable Application
C.6. Portals, Instruction, and Repositories
C.7. Mailing Lists
C.8. Books
C.9. Unix Scripting
About the Author
Colophon
← Prev
Back
Next →
← Prev
Back
Next →