Foreword |
|
xxi | |
Acknowledgments |
|
xxiii | |
Introduction |
|
xxv | |
|
Part I AppleScript: The Power of Automation |
|
|
1 | (80) |
|
Chapter 1 Introduction to AppleScript Programming |
|
|
3 | (18) |
|
A Brief History of AppleScript |
|
|
5 | (2) |
|
Finding AppleScript Resources |
|
|
7 | (3) |
|
|
8 | (1) |
|
|
9 | (1) |
|
|
9 | (1) |
|
Understanding the Unique Characteristics of AppleScript |
|
|
10 | (4) |
|
|
10 | (3) |
|
|
13 | (1) |
|
|
13 | (1) |
|
Consistency maintained between updates |
|
|
14 | (1) |
|
Exploring the Uses and Users of AppleScript |
|
|
14 | (4) |
|
|
15 | (3) |
|
|
18 | (1) |
|
Respecting the Power of AppleScript |
|
|
18 | (1) |
|
|
19 | (2) |
|
Chapter 2 Workflow Automation with AppleScript |
|
|
21 | (10) |
|
Defining Workflow Automation |
|
|
22 | (4) |
|
Busting some myths about automation |
|
|
22 | (3) |
|
Exploring reasons to automate a workflow |
|
|
25 | (1) |
|
Using AppleScript for Workflow Automation |
|
|
26 | (4) |
|
Understanding the scalability of AppleScript |
|
|
27 | (2) |
|
Quantifying the return on investment potential of AppleScript |
|
|
29 | (1) |
|
|
30 | (1) |
|
Chapter 3 AppleScript Deployment Options |
|
|
31 | (28) |
|
Exploring AppleScript Formats |
|
|
31 | (8) |
|
|
32 | (4) |
|
Saving scripts as applications |
|
|
36 | (3) |
|
Exploring Script Deployment Locations |
|
|
39 | (17) |
|
Mac OS X installation locations |
|
|
39 | (8) |
|
|
47 | (6) |
|
Third-party application locations |
|
|
53 | (3) |
|
Choosing a Format and Location |
|
|
56 | (2) |
|
|
58 | (1) |
|
Chapter 4 Making the Case for Standardization |
|
|
59 | (22) |
|
Understanding the Benefits of Standards |
|
|
59 | (2) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
61 | (1) |
|
|
61 | (1) |
|
|
61 | (1) |
|
Exploring the Flexibility of Standards |
|
|
61 | (1) |
|
Applying standards within a context |
|
|
61 | (1) |
|
Setting your own standards |
|
|
62 | (1) |
|
Defining AppleScript Naming Standards |
|
|
62 | (9) |
|
The goals of naming standards |
|
|
62 | (3) |
|
|
65 | (2) |
|
|
67 | (4) |
|
Defining AppleScript Usage Standards |
|
|
71 | (9) |
|
The goals of usage standards |
|
|
71 | (1) |
|
AppleScript usage standards |
|
|
72 | (8) |
|
|
80 | (1) |
|
Part II Learning the AppleScript Language |
|
|
81 | (230) |
|
Chapter 5 Exploring AppleScript Basics |
|
|
83 | (28) |
|
Understanding AppleScript Terminology |
|
|
83 | (17) |
|
|
84 | (1) |
|
|
84 | (1) |
|
|
85 | (2) |
|
|
87 | (2) |
|
|
89 | (6) |
|
|
95 | (2) |
|
|
97 | (2) |
|
|
99 | (1) |
|
|
99 | (1) |
|
Looking at AppleScript Comments |
|
|
100 | (7) |
|
|
100 | (1) |
|
|
101 | (3) |
|
|
104 | (1) |
|
Commenting usage conventions |
|
|
105 | (2) |
|
|
107 | (3) |
|
|
107 | (2) |
|
|
109 | (1) |
|
|
110 | (1) |
|
Chapter 6 Getting Started with the AppleScript Editor |
|
|
111 | (26) |
|
Exploring the AppleScript Editor User Interface |
|
|
112 | (20) |
|
The script document window |
|
|
112 | (4) |
|
|
116 | (1) |
|
|
116 | (6) |
|
|
122 | (5) |
|
|
127 | (2) |
|
|
129 | (3) |
|
Building the "Hello World" Script |
|
|
132 | (4) |
|
|
132 | (2) |
|
|
134 | (2) |
|
|
136 | (1) |
|
Chapter 7 Working with Text Objects |
|
|
137 | (22) |
|
Introduction to Text Objects |
|
|
137 | (3) |
|
|
137 | (3) |
|
Special consideration for quotes |
|
|
140 | (1) |
|
|
140 | (10) |
|
|
140 | (2) |
|
|
142 | (3) |
|
|
145 | (2) |
|
Considering and ignoring text |
|
|
147 | (3) |
|
|
150 | (7) |
|
|
150 | (1) |
|
|
150 | (1) |
|
|
151 | (3) |
|
Converting text to other data types |
|
|
154 | (1) |
|
Using text item delimiters |
|
|
155 | (2) |
|
|
157 | (2) |
|
Chapter 8 Working with Numbers and Unit Types |
|
|
159 | (12) |
|
Introduction to Number Objects |
|
|
159 | (3) |
|
Looking at types of numbers |
|
|
159 | (1) |
|
Putting a number into a variable |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
162 | (5) |
|
|
162 | (3) |
|
|
165 | (2) |
|
Working with Measurement Unit Types |
|
|
167 | (2) |
|
|
168 | (1) |
|
Converting within the type group |
|
|
168 | (1) |
|
Converting to other data types |
|
|
168 | (1) |
|
|
169 | (2) |
|
Chapter 9 Working with Dates and Times |
|
|
171 | (10) |
|
Introduction to Date Objects |
|
|
171 | (4) |
|
|
172 | (3) |
|
Manipulating Date and Time |
|
|
175 | (4) |
|
|
175 | (2) |
|
Performing calculations with dates and times |
|
|
177 | (2) |
|
|
179 | (2) |
|
Chapter 10 Other AppleScript Data Classes |
|
|
181 | (8) |
|
|
181 | (1) |
|
|
182 | (1) |
|
|
183 | (2) |
|
|
185 | (1) |
|
|
186 | (2) |
|
|
188 | (1) |
|
Chapter 11 Working with Lists |
|
|
189 | (16) |
|
|
189 | (3) |
|
Looking at list properties |
|
|
190 | (1) |
|
Looking at specialty lists |
|
|
191 | (1) |
|
|
192 | (5) |
|
|
192 | (1) |
|
|
193 | (3) |
|
Considering and ignoring text properties |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
197 | (6) |
|
Converting lists to other data types |
|
|
198 | (1) |
|
|
198 | (3) |
|
|
201 | (1) |
|
Replacing items in a list |
|
|
202 | (1) |
|
Removing items from a list |
|
|
202 | (1) |
|
|
203 | (2) |
|
Chapter 12 Working with Records |
|
|
205 | (8) |
|
|
205 | (2) |
|
Comparing an AppleScript record to a database record |
|
|
206 | (1) |
|
Looking at record properties |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
208 | (2) |
|
|
208 | (1) |
|
|
208 | (2) |
|
Considering and ignoring text properties |
|
|
210 | (1) |
|
|
210 | (2) |
|
Converting records to other data types |
|
|
210 | (1) |
|
Extracting data from a record |
|
|
210 | (1) |
|
Adding something to a record |
|
|
211 | (1) |
|
Replacing a value in a record |
|
|
211 | (1) |
|
Removing a value from a record |
|
|
212 | (1) |
|
|
212 | (1) |
|
Chapter 13 Logical Branching |
|
|
213 | (14) |
|
Looking at the Anatomy of an If-then Statement |
|
|
213 | (4) |
|
Building a conditional "Hello World" dialog |
|
|
214 | (1) |
|
|
215 | (2) |
|
Creating a Multiple Condition Statement |
|
|
217 | (2) |
|
Adding Additional Conditions |
|
|
219 | (2) |
|
|
221 | (1) |
|
Understanding Common Mistakes |
|
|
222 | (3) |
|
|
223 | (1) |
|
|
223 | (1) |
|
Condltionally undefined variables |
|
|
224 | (1) |
|
|
225 | (2) |
|
|
227 | (18) |
|
Looking at the Anatomy of a Repeat Statement |
|
|
228 | (1) |
|
Defining the Types of Repeat Loops |
|
|
229 | (4) |
|
|
229 | (1) |
|
|
230 | (1) |
|
|
230 | (1) |
|
|
231 | (1) |
|
Repeat with a from x to y {by z} |
|
|
231 | (2) |
|
|
233 | (1) |
|
|
233 | (2) |
|
|
235 | (8) |
|
Creating with repeat loops |
|
|
235 | (1) |
|
Modifying with repeat loops |
|
|
236 | (4) |
|
Extracting with repeat loops |
|
|
240 | (2) |
|
Processing files with repeat loops |
|
|
242 | (1) |
|
|
243 | (2) |
|
Chapter 15 Dealing with Script Errors |
|
|
245 | (22) |
|
Introduction to Script Errors |
|
|
245 | (6) |
|
Defining programming errors |
|
|
246 | (3) |
|
Defining situational errors |
|
|
249 | (2) |
|
Exploring Error Management |
|
|
251 | (10) |
|
Looking at the anatomy of a try command |
|
|
252 | (6) |
|
|
258 | (1) |
|
Generating your own errors |
|
|
259 | (1) |
|
Understanding cascading errors |
|
|
260 | (1) |
|
Recording Errors Into a Log File |
|
|
261 | (2) |
|
Writing Information to the event log |
|
|
261 | (1) |
|
Writing errors to text files |
|
|
262 | (1) |
|
Looking at the AppleScript and Mac OS X Errors |
|
|
263 | (2) |
|
|
265 | (2) |
|
Chapter 16 Getting Started with Scripting Additions |
|
|
267 | (44) |
|
Finding Scripting Additions |
|
|
267 | (1) |
|
|
267 | (1) |
|
|
268 | (1) |
|
User's Home Library folder |
|
|
268 | (1) |
|
Embedding Scripting Additions |
|
|
268 | (1) |
|
Working with Standard Additions |
|
|
269 | (41) |
|
|
270 | (15) |
|
|
285 | (4) |
|
|
289 | (2) |
|
|
291 | (2) |
|
|
293 | (4) |
|
|
297 | (3) |
|
|
300 | (4) |
|
|
304 | (5) |
|
|
309 | (1) |
|
|
310 | (1) |
|
Part III Using Scripts to Control Applications |
|
|
311 | (98) |
|
Chapter 17 Controlling Applications with Scripts |
|
|
313 | (26) |
|
Introduction to Application Automation |
|
|
313 | (9) |
|
Looking at the "tell application" statement |
|
|
314 | (1) |
|
|
314 | (2) |
|
Ignoring an application response |
|
|
316 | (1) |
|
Respecting hierarchy when nesting disparate control commands |
|
|
317 | (1) |
|
Defining different types of AppleScript support |
|
|
318 | (4) |
|
Exploring an Application's Dictionary |
|
|
322 | (6) |
|
|
322 | (1) |
|
Exploring the dictionary interface |
|
|
323 | (1) |
|
Exploring an application's dictionary content |
|
|
324 | (4) |
|
Using AppleScript to Control Applications |
|
|
328 | (6) |
|
Activating, launching, and quitting applications |
|
|
328 | (1) |
|
Manipulating the Finder with scripts |
|
|
329 | (5) |
|
Controlling Inter-Application Communication |
|
|
334 | (1) |
|
Controlling Remote Applications |
|
|
335 | (3) |
|
Configuring Remote Apple Events |
|
|
335 | (1) |
|
Understanding eppc computer specifiers |
|
|
336 | (1) |
|
Sending commands to a remote application |
|
|
337 | (1) |
|
Compiling a script using terms from a local application |
|
|
337 | (1) |
|
|
338 | (1) |
|
Chapter 18 Working with Image Events |
|
|
339 | (22) |
|
Introduction to Image Events |
|
|
339 | (15) |
|
Getting started with basic functionality |
|
|
340 | (5) |
|
Reading properties of an image file |
|
|
345 | (3) |
|
|
348 | (6) |
|
Creating an Image Batch Processor |
|
|
354 | (5) |
|
|
359 | (2) |
|
Chapter 19 Working with Database Events |
|
|
361 | (24) |
|
Introduction to Database Events |
|
|
361 | (11) |
|
Getting started with basic functionality |
|
|
362 | (4) |
|
Working with database records |
|
|
366 | (2) |
|
|
368 | (4) |
|
|
372 | (7) |
|
Searching for text values |
|
|
372 | (3) |
|
Searching for numeric values |
|
|
375 | (1) |
|
Searching for date values |
|
|
376 | (2) |
|
Searching for multiple values |
|
|
378 | (1) |
|
Importing Records from Tab-Separated Files |
|
|
379 | (5) |
|
|
384 | (1) |
|
Chapter 20 Working with System Events |
|
|
385 | (24) |
|
Introduction to System Events |
|
|
385 | (8) |
|
Getting started with basic functionality |
|
|
386 | (1) |
|
Exploring the suites of commands |
|
|
387 | (6) |
|
Controlling Non-Scriptable Applications |
|
|
393 | (14) |
|
Enabling User Interface Scripting |
|
|
393 | (2) |
|
Activating and targeting applications |
|
|
395 | (1) |
|
Referencing objects in an application's interface |
|
|
396 | (4) |
|
Accessing information from an interface |
|
|
400 | (4) |
|
Performing User Interface Scripting actions |
|
|
404 | (3) |
|
Creating a Zipped Archive File with System Events |
|
|
407 | (1) |
|
|
408 | (1) |
|
Part IV Using Subroutines and Open-Ended Programming |
|
|
409 | (92) |
|
Chapter 21 Using Subroutines for Non-Linear Programming |
|
|
411 | (22) |
|
|
413 | (12) |
|
Calling a subroutine from a tell application statement |
|
|
414 | (1) |
|
Exchanging data with subroutines |
|
|
415 | (6) |
|
Identifying command handler subroutines |
|
|
421 | (3) |
|
|
424 | (1) |
|
Exploring the Benefits of Subroutines |
|
|
425 | (5) |
|
|
425 | (3) |
|
|
428 | (1) |
|
Allowing advanced script design |
|
|
429 | (1) |
|
Resolving variable names conflicts |
|
|
429 | (1) |
|
Designing a Non-Linear Script |
|
|
430 | (2) |
|
Understanding when to delimit a script Into subroutines |
|
|
430 | (1) |
|
Looking at the methods of delimiting a script |
|
|
431 | (1) |
|
|
432 | (1) |
|
Chapter 22 Introduction to Open-Ended Programming |
|
|
433 | (36) |
|
Understanding the Benefits of Open-Ended Code |
|
|
434 | (1) |
|
Makes recycling code easy |
|
|
434 | (1) |
|
|
434 | (1) |
|
|
435 | (1) |
|
Justifies smaller scripts |
|
|
435 | (1) |
|
|
435 | (10) |
|
Use repeat loops to remove duplicate code |
|
|
437 | (1) |
|
|
438 | (1) |
|
Provide for an empty selection |
|
|
439 | (1) |
|
Allow folders to be processed |
|
|
440 | (1) |
|
Dynamically count the name's length |
|
|
440 | (1) |
|
|
441 | (1) |
|
Use variables or script properties |
|
|
442 | (1) |
|
|
443 | (1) |
|
|
443 | (2) |
|
Creating Open-Ended Subroutines |
|
|
445 | (6) |
|
Divide code with logical groupings |
|
|
445 | (1) |
|
|
446 | (1) |
|
Name subroutines, parameters, and variables generically |
|
|
447 | (1) |
|
Avoid branch-style openness |
|
|
448 | (1) |
|
Use subroutine parameters for variable input |
|
|
449 | (1) |
|
Use records for future parameter expansion |
|
|
450 | (1) |
|
Keep subroutines as portable as possible |
|
|
451 | (1) |
|
Creating an Open-Ended Image Batch Processor |
|
|
451 | (17) |
|
Allow a user to select folders |
|
|
451 | (1) |
|
Enable two additional selection methods |
|
|
452 | (2) |
|
|
454 | (1) |
|
Select a custom scale percentage |
|
|
455 | (3) |
|
Allow the user to choose an output format |
|
|
458 | (1) |
|
Allow the selection of multiple output formats |
|
|
459 | (2) |
|
|
461 | (3) |
|
|
464 | (1) |
|
|
464 | (4) |
|
|
468 | (1) |
|
Chapter 23 Designing a Hierarchical Subroutine Structure |
|
|
469 | (32) |
|
Defining the Goals of Subroutine Hierarchy |
|
|
472 | (1) |
|
Produce a flexible and expandable script |
|
|
473 | (1) |
|
|
473 | (1) |
|
|
473 | (1) |
|
Achieve a separation of data from function |
|
|
473 | (1) |
|
Facilitate a multi-module solution ideology |
|
|
473 | (1) |
|
Identifying the Primary Levels of Hierarchy |
|
|
473 | (2) |
|
Maintaining flexibility within levels |
|
|
475 | (1) |
|
Following proper inter-level communication |
|
|
475 | (1) |
|
Identifying Hierarchy-Related Issues |
|
|
475 | (8) |
|
Project-specific elements |
|
|
476 | (2) |
|
|
478 | (5) |
|
Creating a Image Batch Processor with a Hierarchical Subroutine Structure |
|
|
483 | (16) |
|
Outlining the new subroutine structure |
|
|
487 | (1) |
|
|
488 | (11) |
|
|
499 | (2) |
|
Part V Organizing Code into Modules and Libraries for Multi-Module Solutions |
|
|
501 | (62) |
|
Chapter 24 Introduction to Multi-Module Solutions |
|
|
503 | (32) |
|
Understanding the Benefits of Multi-Module Solutions |
|
|
504 | (1) |
|
|
504 | (1) |
|
Allows advanced script design |
|
|
504 | (1) |
|
Designing a Multi-Module Solution |
|
|
505 | (12) |
|
Defining types of script files |
|
|
505 | (2) |
|
Exploring file structure options for complex solutions |
|
|
507 | (5) |
|
Understanding inter-script communication |
|
|
512 | (5) |
|
Overcoming the Complexities of Multi-Module Solutions |
|
|
517 | (5) |
|
Employing good development habits |
|
|
517 | (2) |
|
|
519 | (3) |
|
Building a Multi-Module Image Batch Processor |
|
|
522 | (12) |
|
Designing the new solution |
|
|
522 | (1) |
|
Building the Logging Module file |
|
|
523 | (5) |
|
Building the Finder Library file |
|
|
528 | (1) |
|
Building the Image Events Library file |
|
|
529 | (1) |
|
Building the main Image Batch Processor file |
|
|
530 | (4) |
|
|
534 | (1) |
|
Chapter 25 Designing Open-Ended, Multi-Module Solutions |
|
|
535 | (28) |
|
|
535 | (12) |
|
Anticipating business changes |
|
|
535 | (7) |
|
Anticipating development changes |
|
|
542 | (5) |
|
Upgrading the Image Batch Processor to an Open-Ended, Multi-Module Solution |
|
|
547 | (15) |
|
Creating the new module template |
|
|
547 | (3) |
|
Setting up the Scale module |
|
|
550 | (1) |
|
Setting up the Flip module |
|
|
551 | (1) |
|
Modifying the Image batch processor module |
|
|
552 | (8) |
|
Creating a new Rotate module |
|
|
560 | (2) |
|
Further expansion and inspiration |
|
|
562 | (1) |
|
|
562 | (1) |
|
Appendix: AppleScript Web Resources |
|
|
563 | (4) |
|
Apple's Developer Resources |
|
|
563 | (1) |
|
Developer Connection main page |
|
|
563 | (1) |
|
AppleScript documentation and resource main page |
|
|
563 | (1) |
|
Introduction to AppleScript overview page |
|
|
564 | (1) |
|
AppleScript language guide |
|
|
564 | (1) |
|
AppleScript release notes |
|
|
564 | (1) |
|
|
564 | (1) |
|
Apple's AppleScript Users |
|
|
564 | (1) |
|
Mac Scripting Systems (MACSCRPT) |
|
|
564 | (1) |
|
Alternative Script Editor Software |
|
|
565 | (1) |
|
|
565 | (1) |
|
|
565 | (1) |
|
Additional Scripting-Related Sites |
|
|
565 | (2) |
|
|
565 | (1) |
|
|
565 | (1) |
|
MacTech's Visual Basic to AppleScript guide |
|
|
565 | (1) |
|
|
566 | (1) |
Index |
|
567 | |