Introduction |
|
1 | (1) |
|
Who Should Read This Book |
|
|
2 | (1) |
|
How This Book Is Organized |
|
|
2 | (1) |
|
Conventions Used in This Book |
|
|
3 | (2) |
|
Part I Getting Started with AppleScript |
|
|
5 | (76) |
|
|
7 | (12) |
|
AppleScript Success Stories |
|
|
8 | (2) |
|
|
9 | (1) |
|
Real Estate and Other Listings |
|
|
9 | (1) |
|
|
9 | (1) |
|
Responding to Disk Insertions with Scripts |
|
|
10 | (1) |
|
Scripting Versus Point-and-Click |
|
|
10 | (2) |
|
Using Unused Computer Time |
|
|
11 | (1) |
|
|
11 | (1) |
|
Automating Routine but Simple Tasks |
|
|
11 | (1) |
|
Working with Speech Recognition |
|
|
11 | (1) |
|
Watching for Special Cases and Conditions |
|
|
12 | (1) |
|
What Makes AppleScript Special: Syntactical Scripting |
|
|
12 | (1) |
|
How AppleScript Works: Overview |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
AppleScript Syntax for Programming |
|
|
15 | (2) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
19 | (8) |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
22 | (3) |
|
Installing the Script Menu |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
Running the Scripts You Already Have |
|
|
27 | (12) |
|
|
28 | (3) |
|
|
29 | (1) |
|
Using Scripts to Navigate the Web |
|
|
30 | (1) |
|
Launching an Application with a Script |
|
|
30 | (1) |
|
|
31 | (1) |
|
|
31 | (1) |
|
|
31 | (2) |
|
|
33 | (2) |
|
|
35 | (1) |
|
|
35 | (1) |
|
|
35 | (2) |
|
ColorSync and FontSync Scripts |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
38 | (1) |
|
|
38 | (1) |
|
|
38 | (1) |
|
Getting New Scripts from Apple and Running Them |
|
|
39 | (12) |
|
|
40 | (2) |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
41 | (1) |
|
|
42 | (2) |
|
|
42 | (1) |
|
Create DVD from Folders, Photos, and More |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
44 | (2) |
|
Installing the iTunes Script Menu |
|
|
44 | (1) |
|
Looking Up Artists on eMusic |
|
|
45 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
The EMBED Tag Wizard Script |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (2) |
|
Customizing Your Desktop (Snapshot and Set View Options) |
|
|
47 | (1) |
|
Image Manipulation Scripts |
|
|
47 | (1) |
|
|
48 | (1) |
|
|
48 | (1) |
|
|
49 | (2) |
|
|
49 | (1) |
|
|
49 | (1) |
|
|
49 | (2) |
|
Third-party Scripts and Applications That Simplify Your Life |
|
|
51 | (8) |
|
|
52 | (3) |
|
|
52 | (1) |
|
|
52 | (2) |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
55 | (2) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
57 | (1) |
|
|
57 | (2) |
|
|
57 | (1) |
|
|
57 | (1) |
|
|
58 | (1) |
|
Looking Behind the Scenes: How These Scripts Work |
|
|
59 | (10) |
|
|
60 | (1) |
|
|
61 | (2) |
|
Using Parameters in Subroutines |
|
|
61 | (1) |
|
Using Prepositions with Parameters |
|
|
61 | (2) |
|
|
63 | (2) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
66 | (1) |
|
|
66 | (1) |
|
|
66 | (3) |
|
|
66 | (1) |
|
|
67 | (1) |
|
|
67 | (2) |
|
Basic Programming Concepts |
|
|
69 | (12) |
|
Units of Control and Definition |
|
|
70 | (1) |
|
|
71 | (3) |
|
Simple Conditional Statements |
|
|
72 | (1) |
|
Compound Conditional Statements |
|
|
72 | (1) |
|
|
72 | (1) |
|
Writing Good Conditional Statements |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
74 | (3) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (1) |
|
|
75 | (1) |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
|
78 | (1) |
|
|
78 | (1) |
|
|
79 | (2) |
|
|
79 | (1) |
|
|
79 | (1) |
|
|
79 | (2) |
|
Part II Writing Scripts with Script Editor |
|
|
81 | (76) |
|
Introducing Script Editor |
|
|
83 | (10) |
|
Finding Your Way Around Script Editor |
|
|
84 | (2) |
|
|
84 | (1) |
|
|
85 | (1) |
|
|
86 | (1) |
|
|
86 | (1) |
|
|
86 | (2) |
|
Working with Dictionaries |
|
|
88 | (2) |
|
|
90 | (1) |
|
|
90 | (1) |
|
|
90 | (1) |
|
|
91 | (1) |
|
|
91 | (2) |
|
|
91 | (1) |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
93 | (14) |
|
|
94 | (2) |
|
Telling an Application to Do Something |
|
|
94 | (1) |
|
Telling an Object to Do Something |
|
|
95 | (1) |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
96 | (1) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
97 | (4) |
|
|
97 | (2) |
|
AppleScript-defined Variables |
|
|
99 | (2) |
|
|
101 | (1) |
|
|
101 | (1) |
|
|
101 | (1) |
|
|
101 | (4) |
|
|
102 | (1) |
|
|
103 | (2) |
|
|
105 | (1) |
|
|
105 | (1) |
|
|
105 | (2) |
|
|
106 | (1) |
|
|
106 | (1) |
|
|
106 | (1) |
|
|
107 | (14) |
|
|
108 | (1) |
|
|
109 | (1) |
|
Standard Suite: Terms That Most Applications Support |
|
|
110 | (3) |
|
|
111 | (1) |
|
|
111 | (1) |
|
|
112 | (1) |
|
|
112 | (1) |
|
|
112 | (1) |
|
Other Commands in the Finder Standard Suite |
|
|
112 | (1) |
|
Standard Suite Commands Not Implemented in the Finder |
|
|
112 | (1) |
|
|
113 | (2) |
|
|
114 | (1) |
|
|
115 | (1) |
|
|
115 | (1) |
|
Container and Folders Suite |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
118 | (3) |
|
|
118 | (1) |
|
|
118 | (1) |
|
|
119 | (2) |
|
Scripting Mac OS X Applications from Apple |
|
|
121 | (14) |
|
|
122 | (2) |
|
Find the application Class and Its Elements |
|
|
123 | (1) |
|
Look at the Element Definitions |
|
|
123 | (1) |
|
Repeat for Elements Contained Within Elements |
|
|
124 | (1) |
|
|
124 | (1) |
|
|
125 | (1) |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
130 | (1) |
|
|
131 | (1) |
|
|
132 | (1) |
|
|
132 | (3) |
|
|
132 | (1) |
|
|
132 | (1) |
|
|
132 | (3) |
|
Scripting Mac OS X Applications from Third Parties |
|
|
135 | (12) |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
138 | (2) |
|
Scripting Microsoft Office |
|
|
140 | (1) |
|
|
140 | (1) |
|
|
141 | (1) |
|
Scripting Internet Explorer |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
143 | (2) |
|
|
145 | (1) |
|
|
145 | (1) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
147 | (10) |
|
Telling the User Something |
|
|
148 | (2) |
|
Asking the User Something |
|
|
150 | (1) |
|
Other Ways of Communicating with Users |
|
|
151 | (1) |
|
|
151 | (1) |
|
Using Other Applications for Input and Output |
|
|
152 | (1) |
|
Aqua Human Interface Guidelines |
|
|
152 | (2) |
|
|
154 | (1) |
|
|
154 | (1) |
|
|
154 | (3) |
|
|
154 | (1) |
|
|
155 | (1) |
|
|
155 | (2) |
|
Part III Working with AppleScript Studio |
|
|
157 | (122) |
|
Introducing AppleScript Studio |
|
|
159 | (22) |
|
Getting AppleScript Studio |
|
|
160 | (1) |
|
What Is AppleScript Studio? |
|
|
160 | (4) |
|
AppleScript Studio's Components |
|
|
160 | (2) |
|
Looking at an AppleScript Studio Application |
|
|
162 | (2) |
|
Getting Started with Project Builder |
|
|
164 | (4) |
|
Looking at Interface Builder |
|
|
168 | (11) |
|
|
168 | (4) |
|
Adding Other Interface Elements |
|
|
172 | (2) |
|
|
174 | (5) |
|
|
179 | (1) |
|
|
179 | (1) |
|
|
180 | (1) |
|
|
180 | (1) |
|
|
180 | (1) |
|
|
180 | (1) |
|
Building a Graphical AppleScript Studio Application |
|
|
181 | (20) |
|
Writing a Simple AppleScript Studio Application |
|
|
182 | (5) |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
183 | (1) |
|
|
184 | (3) |
|
|
187 | (1) |
|
|
187 | (1) |
|
A (Very) Little Programming Background |
|
|
187 | (6) |
|
|
189 | (1) |
|
|
190 | (2) |
|
|
192 | (1) |
|
|
192 | (1) |
|
Summing Up the Programming Details |
|
|
193 | (1) |
|
|
193 | (5) |
|
Implementing a Menu Command |
|
|
194 | (1) |
|
Factoring Your Application |
|
|
195 | (1) |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
|
|
198 | (1) |
|
|
199 | (2) |
|
|
199 | (1) |
|
|
199 | (1) |
|
|
199 | (2) |
|
Writing Code for AppleScript Studio |
|
|
201 | (20) |
|
|
202 | (5) |
|
|
203 | (2) |
|
Using a Pop-up Menu to Control a Tab View |
|
|
205 | (2) |
|
Using Pop-up Menus and Combination (Combo) Boxes |
|
|
207 | (3) |
|
Using Connections to Get Pop-up Menu Values |
|
|
208 | (1) |
|
Using AppleScript to Get Pop-up Menu Values |
|
|
209 | (1) |
|
|
210 | (3) |
|
|
211 | (1) |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
212 | (1) |
|
|
213 | (1) |
|
Using the Color Well and Image Views |
|
|
214 | (1) |
|
Using Progress Indicators |
|
|
214 | (1) |
|
|
215 | (3) |
|
|
218 | (1) |
|
|
218 | (1) |
|
|
219 | (2) |
|
|
219 | (1) |
|
|
219 | (1) |
|
|
219 | (2) |
|
Planning and Debugging AppleScript Studio Applications |
|
|
221 | (20) |
|
Project Builder Preferences |
|
|
222 | (1) |
|
|
223 | (8) |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
226 | (2) |
|
|
228 | (2) |
|
|
230 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
Who Should Debug Applications? |
|
|
233 | (1) |
|
When Do You Debug Applications? |
|
|
233 | (1) |
|
Debugging with Script Editor |
|
|
233 | (1) |
|
Debugging with Project Builder |
|
|
233 | (1) |
|
Debugging with Project Builder's Debugger |
|
|
234 | (5) |
|
|
235 | (1) |
|
|
236 | (2) |
|
|
238 | (1) |
|
|
239 | (1) |
|
|
239 | (1) |
|
|
239 | (2) |
|
|
240 | (1) |
|
|
240 | (1) |
|
|
240 | (1) |
|
Adding Help to AppleScript Studio |
|
|
241 | (18) |
|
Eliminating the Need for Help with Application Design |
|
|
242 | (5) |
|
|
243 | (3) |
|
|
246 | (1) |
|
|
247 | (1) |
|
|
248 | (1) |
|
|
248 | (1) |
|
Providing Button-driven Help |
|
|
249 | (5) |
|
Adding an Image to Your Project |
|
|
249 | (3) |
|
|
252 | (2) |
|
Interacting with Help Viewer |
|
|
254 | (1) |
|
|
255 | (1) |
|
|
256 | (1) |
|
|
256 | (3) |
|
|
257 | (1) |
|
|
257 | (1) |
|
|
257 | (2) |
|
Using Documents and Data Sources with AppleScript Studio |
|
|
259 | (20) |
|
Working with Table and Outline Views |
|
|
260 | (2) |
|
Working with Data Sources |
|
|
262 | (6) |
|
|
262 | (1) |
|
|
263 | (1) |
|
Adding Rows to Data Sources |
|
|
264 | (1) |
|
Populating New Rows with Data |
|
|
265 | (2) |
|
Bulk Additions to Data Sources |
|
|
267 | (1) |
|
Extracting Data from Data Sources |
|
|
267 | (1) |
|
Exploring the AppleScript Document Template |
|
|
268 | (4) |
|
Working with Documents: High-level Approach |
|
|
272 | (2) |
|
|
273 | (1) |
|
Retrieving Data from Disk |
|
|
274 | (1) |
|
Working with Files: Low-level Approach |
|
|
274 | (2) |
|
|
275 | (1) |
|
Retrieving Data from a File |
|
|
275 | (1) |
|
|
276 | (1) |
|
|
276 | (1) |
|
|
277 | (2) |
|
|
277 | (1) |
|
|
277 | (1) |
|
|
277 | (2) |
|
Part IV Advanced Scripting |
|
|
279 | (82) |
|
Advanced AppleScript Syntax |
|
|
281 | (16) |
|
|
282 | (10) |
|
|
282 | (1) |
|
Script Objects as Instances |
|
|
283 | (4) |
|
|
287 | (4) |
|
|
291 | (1) |
|
|
292 | (3) |
|
|
295 | (1) |
|
|
295 | (1) |
|
|
295 | (2) |
|
|
296 | (1) |
|
|
296 | (1) |
|
|
296 | (1) |
|
Creating AppleScripts to Control Multiple Applications |
|
|
297 | (14) |
|
|
298 | (2) |
|
|
298 | (1) |
|
|
299 | (1) |
|
|
299 | (1) |
|
Extracting Data from Address Book and Placing It in Text Edit |
|
|
300 | (2) |
|
|
300 | (1) |
|
|
300 | (1) |
|
|
300 | (2) |
|
Extracting Data from FileMaker and Placing It in Text Edit |
|
|
302 | (1) |
|
|
302 | (1) |
|
|
303 | (1) |
|
|
303 | (1) |
|
Extracting Data from Address Book and Placing It in InDesign |
|
|
303 | (3) |
|
|
303 | (1) |
|
|
304 | (1) |
|
|
305 | (1) |
|
Extracting Data from FileMaker and Placing It in InDesign |
|
|
306 | (1) |
|
|
306 | (1) |
|
|
306 | (1) |
|
|
306 | (1) |
|
Creating Dynamic Pages with InDesign |
|
|
306 | (2) |
|
|
307 | (1) |
|
|
307 | (1) |
|
|
307 | (1) |
|
|
308 | (1) |
|
|
309 | (1) |
|
|
309 | (2) |
|
|
309 | (1) |
|
|
310 | (1) |
|
|
310 | (1) |
|
Using AppleScript Across a Network |
|
|
311 | (18) |
|
|
312 | (1) |
|
|
312 | (1) |
|
|
313 | (1) |
|
|
313 | (1) |
|
How AppleScript Works Across a Network |
|
|
313 | (1) |
|
What You Need to Do on the Client Mac |
|
|
314 | (1) |
|
What You Need to Do on the Server Mac |
|
|
315 | (3) |
|
Allowing Remote Connections for File Sharing |
|
|
316 | (1) |
|
Allowing Remote Connections for Apple Events |
|
|
317 | (1) |
|
Setting Up User Accounts for Remote Access |
|
|
317 | (1) |
|
Using AppleScript to Process CGI Requests |
|
|
318 | (3) |
|
|
319 | (1) |
|
Modifying the Script from Apple |
|
|
320 | (1) |
|
|
321 | (4) |
|
|
322 | (1) |
|
|
322 | (3) |
|
Using Web Services with Script Editor |
|
|
325 | (1) |
|
Using Web Services with AppleScript Studio |
|
|
326 | (1) |
|
|
327 | (1) |
|
|
327 | (1) |
|
|
328 | (1) |
|
|
328 | (1) |
|
|
328 | (1) |
|
|
328 | (1) |
|
Beyond AppleScript: Using Services |
|
|
329 | (12) |
|
|
330 | (2) |
|
|
332 | (1) |
|
|
332 | (1) |
|
|
332 | (1) |
|
|
332 | (1) |
|
|
333 | (1) |
|
Enabling Services with AppleScript Studio |
|
|
333 | (4) |
|
Why Use Services with AppleScript Studio? |
|
|
337 | (1) |
|
Services from Script Editor |
|
|
337 | (1) |
|
|
337 | (1) |
|
Get Result of AppleScript |
|
|
337 | (1) |
|
|
338 | (1) |
|
|
338 | (1) |
|
|
338 | (1) |
|
|
338 | (3) |
|
|
339 | (1) |
|
|
339 | (1) |
|
|
339 | (2) |
|
Beyond AppleScript: Shell Scripts, Perl, and Other Scripting Languages |
|
|
341 | (20) |
|
|
342 | (7) |
|
What Commands Are Available? |
|
|
343 | (1) |
|
|
344 | (1) |
|
|
344 | (1) |
|
Using Files for Input, Output, and Errors |
|
|
345 | (1) |
|
|
346 | (1) |
|
Working with Files in Terminal |
|
|
346 | (1) |
|
Listing a Directory and Displaying a File |
|
|
347 | (2) |
|
|
349 | (1) |
|
|
349 | (1) |
|
Running AppleScript from Terminal |
|
|
349 | (3) |
|
Running a Script from Terminal |
|
|
350 | (1) |
|
Running AppleScript Commands from Terminal |
|
|
351 | (1) |
|
Running AppleScript As Commands from Applications |
|
|
352 | (1) |
|
Automatically Running Scripts |
|
|
353 | (3) |
|
|
353 | (1) |
|
|
354 | (2) |
|
Other Scripting Languages |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
357 | (1) |
|
|
357 | (1) |
|
|
357 | (1) |
|
|
358 | (1) |
|
|
358 | (3) |
|
|
358 | (1) |
|
|
358 | (1) |
|
|
359 | (2) |
|
|
361 | (20) |
|
Appendix A Constants and Predefined Variables |
|
|
363 | (4) |
|
|
367 | (4) |
|
|
368 | (1) |
|
|
368 | (1) |
|
|
368 | (1) |
|
|
369 | (1) |
|
|
370 | (1) |
|
Appendix C Third-party Script Editors |
|
|
371 | (10) |
|
|
372 | (2) |
|
|
374 | (3) |
|
|
377 | (4) |
Glossary |
|
381 | (4) |
Index |
|
385 | |