|
Part I INTRODUCING APPLESCRIPT SCRIPTING |
|
|
1 | (76) |
|
|
3 | (32) |
|
Project Preview: The AppleScript Humor Game |
|
|
3 | (3) |
|
|
6 | (2) |
|
Common Tasks Performed by AppleScripts |
|
|
8 | (5) |
|
Automating Complex and Repetitive Tasks |
|
|
8 | (2) |
|
Automating the Execution and Operation of Mac OS X Applications |
|
|
10 | (2) |
|
Developing Application Workflows |
|
|
12 | (1) |
|
Operating System Integration |
|
|
13 | (6) |
|
|
13 | (2) |
|
Accessing AppleScripts through the Script Menu |
|
|
15 | (4) |
|
A Quick Introduction to the Script Editor |
|
|
19 | (6) |
|
Creating Your First AppleScript |
|
|
20 | (1) |
|
|
20 | (2) |
|
|
22 | (1) |
|
Working with Different Types of Script Files |
|
|
23 | (2) |
|
Understanding AppleScript Syntax |
|
|
25 | (2) |
|
Back to the AppleScript Humor Game |
|
|
27 | (6) |
|
|
27 | (4) |
|
Running Your New AppleScript Game |
|
|
31 | (2) |
|
|
33 | (2) |
|
Getting Comfortable With The Applescript Script Editor |
|
|
35 | (42) |
|
Project Preview: The AppleScript Story Teller Game |
|
|
35 | (4) |
|
Introducing the Script Editor |
|
|
39 | (7) |
|
Creating and Running Scripts |
|
|
40 | (2) |
|
|
42 | (1) |
|
|
43 | (3) |
|
Configuring Script Editor Preferences |
|
|
46 | (3) |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
48 | (1) |
|
|
48 | (1) |
|
|
49 | (1) |
|
Configuring the Script Editor Toolbar |
|
|
49 | (2) |
|
Using Advanced Script Editor Features |
|
|
51 | (5) |
|
Working with the Navigation Bar |
|
|
51 | (1) |
|
Using Context Generated Code Snippets |
|
|
52 | (3) |
|
Leveraging the Power of the Script Assistant |
|
|
55 | (1) |
|
Researching Application Dictionaries |
|
|
56 | (3) |
|
Working with the Dictionary Browser |
|
|
56 | (2) |
|
Taking Advantage of the Library Palette |
|
|
58 | (1) |
|
|
59 | (8) |
|
|
59 | (2) |
|
|
61 | (3) |
|
|
64 | (3) |
|
Back to the AppleScript Story Teller Game |
|
|
67 | (7) |
|
|
68 | (6) |
|
Running Your New AppleScript Game |
|
|
74 | (1) |
|
|
74 | (3) |
|
Part II Learning How to Write Applescripts |
|
|
77 | (118) |
|
Working With Values, Variables, and Classes |
|
|
79 | (34) |
|
Project Preview: The AppleScript Fortune Teller Game |
|
|
80 | (1) |
|
Communicating with the User |
|
|
81 | (5) |
|
|
82 | (2) |
|
Displaying Alert Messages |
|
|
84 | (1) |
|
Letting the User Select from a List |
|
|
85 | (1) |
|
|
86 | (1) |
|
AppleScript Commands and Statements |
|
|
86 | (5) |
|
|
87 | (1) |
|
Improving Statement Readability with Optional Words |
|
|
87 | (1) |
|
Using English Words and Phrases |
|
|
88 | (1) |
|
Singular and Plural Words |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
89 | (1) |
|
|
89 | (2) |
|
|
91 | (2) |
|
Assigning Data to Variables |
|
|
91 | (1) |
|
Retrieving Data from Variables |
|
|
92 | (1) |
|
|
92 | (1) |
|
AppleScript's Rules for Naming Variables |
|
|
93 | (3) |
|
Variable Names and Case-Sensitivity |
|
|
95 | (1) |
|
Beware of Undefined Variables |
|
|
95 | (1) |
|
Understanding AppleScript Variable Classes |
|
|
96 | (5) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
98 | (1) |
|
|
98 | (1) |
|
|
99 | (1) |
|
Determining a Value's Class |
|
|
100 | (1) |
|
|
101 | (1) |
|
Taking Advantage of Constants |
|
|
102 | (1) |
|
Back to the AppleScript Fortune Teller Game |
|
|
103 | (7) |
|
|
103 | (7) |
|
Testing the Execution of the AppleScript Fortune Teller Game |
|
|
110 | (1) |
|
|
110 | (3) |
|
Implementing Conditional Logic and Working With Loops |
|
|
113 | (30) |
|
Project Preview: The AppleScript Typing Test Game |
|
|
114 | (3) |
|
Fundamentals of Conditional Logic |
|
|
117 | (5) |
|
Implementing Conditional Logic Using the if Statement |
|
|
118 | (1) |
|
Providing for an Alternative Course of Action |
|
|
119 | (1) |
|
Examining Multiple Conditions |
|
|
120 | (1) |
|
Implementing Complex Logic By Nesting If Statements |
|
|
121 | (1) |
|
Performing Different Comparison Operations |
|
|
122 | (2) |
|
Analyzing Mathematical Expressions |
|
|
124 | (1) |
|
Using Compound Operators to Build Complex Conditional Logic |
|
|
124 | (2) |
|
Using Loops to Perform Repetitive Actions |
|
|
126 | (7) |
|
|
127 | (2) |
|
Looping a Specific Number of Times |
|
|
129 | (1) |
|
Looping as Long as a Condition Is True |
|
|
130 | (1) |
|
Looping as Long as a Condition Is False |
|
|
131 | (1) |
|
Using a Counter to Control a Loop's Execution |
|
|
132 | (1) |
|
Using Loops to Process Lists |
|
|
133 | (1) |
|
Back to the AppleScript Typing Test Game |
|
|
133 | (7) |
|
|
134 | (6) |
|
Testing the Execution of the AppleScript Typing Test |
|
|
140 | (1) |
|
|
140 | (3) |
|
Using Strings, Lists, and Records |
|
|
143 | (26) |
|
Project Preview: The Godfather Trivia Quiz |
|
|
144 | (2) |
|
|
146 | (7) |
|
Storing Strings in Variables |
|
|
146 | (1) |
|
Retrieving String Information |
|
|
146 | (1) |
|
Concatenating Strings Together |
|
|
147 | (1) |
|
|
147 | (3) |
|
|
150 | (2) |
|
Accessing Different Parts of a String |
|
|
152 | (1) |
|
Storing and Retrieving Data Using Lists |
|
|
153 | (3) |
|
Populating a List with Data |
|
|
154 | (1) |
|
|
154 | (1) |
|
Reversing the Order of Items in a List |
|
|
155 | (1) |
|
|
155 | (1) |
|
|
156 | (1) |
|
|
156 | (3) |
|
|
157 | (1) |
|
Changing Record Value Assignments |
|
|
158 | (1) |
|
Creating a Small Database Using Lists and Records |
|
|
159 | (1) |
|
Searching String, Lists, and Records |
|
|
159 | (2) |
|
Back to the Godfather Trivia Quiz |
|
|
161 | (6) |
|
|
161 | (6) |
|
Testing the Execution of the Godfather Trivia Quiz |
|
|
167 | (1) |
|
|
167 | (2) |
|
Improving Script Organization with Handlers |
|
|
169 | (26) |
|
Project Preview: The AppleScript Shell Game |
|
|
170 | (2) |
|
Leveraging the Power and Convenience of Handlers |
|
|
172 | (6) |
|
Developing Your Own Custom Handlers |
|
|
172 | (1) |
|
Creating and Calling Upon Custom Handlers |
|
|
173 | (1) |
|
Developing Custom Handlers That Process Arguments |
|
|
174 | (3) |
|
Creating Handlers That Return a Result |
|
|
177 | (1) |
|
Using Event Handlers to Initiate Action |
|
|
178 | (4) |
|
Working with the run Event |
|
|
178 | (1) |
|
Working with the open Event |
|
|
179 | (1) |
|
Working with the idle Event |
|
|
180 | (1) |
|
Working with the quit Event |
|
|
180 | (1) |
|
Working with the reopen Event |
|
|
180 | (1) |
|
A Quick Event Handler Example |
|
|
181 | (1) |
|
Understanding a Handler's Effect on Variable Scope |
|
|
182 | (3) |
|
Working with Local Variables |
|
|
182 | (1) |
|
Creating Global Variables |
|
|
182 | (3) |
|
Back to the AppleScript Shell Game |
|
|
185 | (8) |
|
|
185 | (7) |
|
Testing the Execution of the AppleScript Shell Game |
|
|
192 | (1) |
|
|
193 | (2) |
|
|
195 | (124) |
|
Accessing Files and Folders |
|
|
197 | (30) |
|
Project Preview: The AppleScript Lottery Picker Game |
|
|
197 | (2) |
|
Working with the Mac OS X File System |
|
|
199 | (2) |
|
|
200 | (1) |
|
|
200 | (1) |
|
Specifying a Folder's Path |
|
|
200 | (1) |
|
Working with Full and Relative Paths |
|
|
201 | (1) |
|
Retrieving File and Folder Information |
|
|
202 | (1) |
|
Working with the File Class |
|
|
203 | (2) |
|
Referencing Commonly Accessed Folders |
|
|
203 | (1) |
|
Setting Up File References Using Path Arguments |
|
|
204 | (1) |
|
Writing AppleScripts That Interact with Text Files |
|
|
205 | (8) |
|
Programmatically Opening a Text File |
|
|
206 | (1) |
|
Choosing a File Using the choose file Command |
|
|
206 | (1) |
|
|
207 | (1) |
|
Reading from and Writing to Text Files |
|
|
208 | (5) |
|
|
213 | (1) |
|
Back to the AppleScript Shell Game |
|
|
214 | (11) |
|
|
214 | (11) |
|
Testing the Execution of AppleScript Lottery Picker Game |
|
|
225 | (1) |
|
|
225 | (2) |
|
Automating Mac Os X Applications |
|
|
227 | (28) |
|
Project Preview: The AppleScript Number Guessing Game |
|
|
228 | (1) |
|
Bossing Around Your Mac OS X Applications |
|
|
229 | (1) |
|
Taking Advantage of AppleScripts to Which You Already Have Access |
|
|
230 | (1) |
|
Figuring Out How to Communicate with Mac OS X Applications |
|
|
231 | (4) |
|
Digging into Application Dictionaries |
|
|
232 | (2) |
|
Using Universal Application Commands |
|
|
234 | (1) |
|
Sending Commands to Mac OS X Applications |
|
|
235 | (1) |
|
Automating Mac OS X Applications |
|
|
235 | (10) |
|
Using iTunes to Play Music |
|
|
235 | (1) |
|
|
236 | (3) |
|
Executing Command-Line Commands |
|
|
239 | (1) |
|
|
240 | (1) |
|
|
240 | (1) |
|
|
241 | (1) |
|
Telling Safari to Load Web Pages |
|
|
242 | (1) |
|
|
242 | (2) |
|
Automating the Help Viewer Application |
|
|
244 | (1) |
|
Back to the AppleScript Number Guessing Game |
|
|
245 | (8) |
|
|
245 | (8) |
|
Testing the Execution of the AppleScript Number Guessing Game |
|
|
253 | (1) |
|
|
253 | (2) |
|
Debugging Your Applescripts |
|
|
255 | (28) |
|
Project Preview: The Rock, Paper, Scissors Game |
|
|
255 | (2) |
|
Examining the Three Basic Types of Errors |
|
|
257 | (4) |
|
|
257 | (1) |
|
Coping with Runtime Errors |
|
|
258 | (2) |
|
Dealing with Logical Errors |
|
|
260 | (1) |
|
|
261 | (1) |
|
|
261 | (5) |
|
Catching Errors with the try Statement |
|
|
262 | (2) |
|
Specifying Recovery Actions Using an on error Handler |
|
|
264 | (1) |
|
|
264 | (2) |
|
Monitoring AppleScript Execution |
|
|
266 | (5) |
|
Tracking Script Execution and Variable Values Using Dialog Windows |
|
|
266 | (2) |
|
Using Sound to Track Key Events |
|
|
268 | (1) |
|
Working with the Event Log |
|
|
268 | (3) |
|
Back to the Rock, Paper, Scissors Game |
|
|
271 | (11) |
|
|
271 | (11) |
|
Testing the Execution of the Rock, Paper, Scissors Game |
|
|
282 | (1) |
|
|
282 | (1) |
|
Introducing Applescript Studio |
|
|
283 | (36) |
|
Project Preview: The Tic-Tac-Toe Game |
|
|
284 | (1) |
|
Introducing AppleScript Studio |
|
|
285 | (2) |
|
Building Mac OS X Applications with Xcode |
|
|
286 | (1) |
|
Understanding the Cocoa Framework |
|
|
286 | (1) |
|
Crafting Graphical User Interfaces Using Interface Builder |
|
|
287 | (1) |
|
|
287 | (2) |
|
Getting Comfortable with the Xcode Project Window |
|
|
289 | (5) |
|
Examining the Project Window Toolbar |
|
|
290 | (1) |
|
Understanding Groups & Files |
|
|
290 | (2) |
|
Displaying Detailed Project Information |
|
|
292 | (1) |
|
Working with Xcode's Code Editor |
|
|
292 | (2) |
|
Examining the Info Window |
|
|
294 | (1) |
|
Other Key AppleScript Studio Components |
|
|
294 | (5) |
|
|
295 | (2) |
|
|
297 | (1) |
|
|
298 | (1) |
|
Creating Graphical User Interfaces Using Interface Builder |
|
|
299 | (2) |
|
Working with Cocoa Controls |
|
|
300 | (1) |
|
|
301 | (1) |
|
Back to the Tic-Tac-Toe Game |
|
|
301 | (16) |
|
Step 1: Creating a New Project |
|
|
302 | (1) |
|
Step 2: Creating the User Interface |
|
|
302 | (1) |
|
Step 3: Setting Control Properties |
|
|
303 | (4) |
|
Step 4: Adding a Little Programming Logic |
|
|
307 | (10) |
|
Step 5: Testing the Tic-Tac-Toe Game |
|
|
317 | (1) |
|
|
317 | (2) |
|
Appendix A What's on the Companion Website? |
|
|
319 | (4) |
|
|
323 | (8) |
|
|
323 | (1) |
|
Locating AppleScript Studio Resources Online |
|
|
324 | (3) |
|
Apple's AppleScript Web Pages |
|
|
325 | (1) |
|
AppleScript Reference Library |
|
|
325 | (1) |
|
|
326 | (1) |
|
Apple's AppleScript Studio Web Pages |
|
|
327 | (1) |
|
AppleScript Mailing Lists |
|
|
327 | (4) |
|
Apple's AppleScript-Users Mailing List |
|
|
328 | (1) |
|
Yahoo! Groups: AppleScript Mailing List |
|
|
328 | (1) |
|
MacScripter's AppleScript Forum |
|
|
329 | (2) |
Glossary |
|
331 | (6) |
Index |
|
337 | |