Book description
AppleScript is an English-like, easy-to-understand scripting language built into every Mac. AppleScript can automate hundreds of AppleScriptable applications, performing tasks both large and small, complex and simple.
Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X, Third Edition has been completely updated for Mac OS X Snow Leopard. It's all here, with an emphasis on practical information that will help you solve any automation problem—from the most mundane repetitive tasks to highly integrated workflows of complex systems.
Friendly enough for beginners, detailed enough for advanced AppleScripters
Includes major contributions from expert AppleScripters: Emmanuel Levy, Harald Monihart, Ian Piper, Shane Stanley, Barry Wainwright, Craig Williams, and foreword by AppleScript inventor, William Cook
Table of contents
- Copyright
- Foreword
- About the Authors
- About the Technical Reviewer
- Acknowledgments
- Introduction
-
1. Welcome to AppleScript
- 1. Introducing AppleScript
-
2. AppleScript in Principle
- 2.1. The Four Key Concepts of Application Scripting
- 2.2. The Four Key Concepts of the AppleScript Language
- 2.3. Tying It All Together: What Makes AppleScript Special
- 2.4. Summary
- 3. AppleScript in Practice
-
2. Understanding AppleScript
- 4. Writing Scripts in AppleScript Editor
-
5. Understanding How Application Scripting Works
- 5.1. A Quick Application Scripting Example
- 5.2. Understanding Objects
- 5.3. Understanding Commands
- 5.4. Understanding the Application Object Model
- 5.5. Understanding Application Dictionaries
- 5.6. More on application Objects
-
5.7. More on Constructing References
- 5.7.1. Referring to Properties
-
5.7.2. Referring to Elements
- 5.7.2.1. Identifying All Elements
- 5.7.2.2. Identifying an Element by Its Index, or Position
- 5.7.2.3. Identifying an Element by Its Name
- 5.7.2.4. Identifying an Element by Its Unique ID
- 5.7.2.5. Identifying an Element Before or After Another Element
- 5.7.2.6. Identifying a Range of Elements
- 5.7.2.7. Identifying Elements Using the whose Clause
- 5.7.3. Referring to Insertion Locations
- 5.8. Summary
-
6. Learning to Work with AppleScript Objects
- 6.1. How AppleScript Represents Information As Objects
- 6.2. How AppleScript Works with Objects
- 6.3. Working with Boolean Objects
- 6.4. Summary
- 7. Working with Text
- 8. Working with Numbers
-
9. Working with Dates
- 9.1. Introducing Dates
-
9.2. The Properties of Dates
- 9.2.1. The class Property
- 9.2.2. The year Property
- 9.2.3. The month Property
- 9.2.4. The day Property
- 9.2.5. The weekday Property
- 9.2.6. The hours Property
- 9.2.7. The minutes Property
- 9.2.8. The seconds Property
- 9.2.9. The time Property
- 9.2.10. The date string Property
- 9.2.11. The short date string Property
- 9.2.12. The time string Property
- 9.2.13. Setting Date Properties
- 9.3. Operators and Commands
- 9.4. Example Projects
- 9.5. Summary
-
10. Working with Lists and Records
- 10.1. Introducing Lists and Records
-
10.2. Working with Lists
- 10.2.1. The Properties of a List
- 10.2.2. The Elements of a List
- 10.2.3. Operators and Commands
- 10.2.4. Processing List Items with a Repeat Loop
- 10.2.5. Sorting Items in a List
- 10.3. Working with Records
- 10.4. Example Project: Measuring Word Frequency in TextEdit
- 10.5. Summary
-
11. Storing Objects in Variables
- 11.1. Creating Variables
- 11.2. Working with Local Variables
- 11.3. Working with Properties and Global Variables
- 11.4. Using AppleScript's Built-in Variables
- 11.5. Summary
-
12. More on Commands
- 12.1. Understanding How and Where Commands Are Defined
- 12.2. Picking the Right Target for Your Commands
- 12.3. The Five Standard AppleScript Commands
- 12.4. Commands That All Applications Understand
- 12.5. The Standard Suite of Application Commands
- 12.6. More on Working with get, set, and copy Commands
- 12.7. Changing How Commands Are Handled
-
12.8. Sending Commands to Remote Applications
- 12.8.1. Enabling Remote Apple Events
- 12.8.2. Talking to Remote Machines
- 12.8.3. Authenticating Access to Remote Machines
- 12.8.4. Compiling Scripts Offline
- 12.8.5. Using the choose remote application Command
- 12.8.6. Targeting Remote Applications by User and Process IDs
- 12.8.7. Launching Remote Applications
- 12.9. Summary
- 13. More on Operators and Coercions
-
14. Making Decisions Using Conditionals and Loops
- 14.1. Choosing Your Course with Conditional Blocks
- 14.2. Running an Assembly Line with Repeat Loops
- 14.3. Summary
-
15. Making Decisions When Dealing with Errors
- 15.1. Understanding Compilation Errors
- 15.2. Understanding Runtime Errors
- 15.3. Understanding Common Error Numbers
- 15.4. Summary
-
16. Interacting with the User
-
16.1. Creating Basic Dialog Boxes and Gathering Text Input
-
16.1.1. Introducing the display dialog Command
- 16.1.1.1. From the Dictionary: display dialog
- 16.1.1.2. From the Dictionary: dialog reply
- 16.1.1.3. Using the Basic Form of the Command
- 16.1.1.4. Dealing with the Erroneous Cancel Button
- 16.1.1.5. Creating Custom Buttons
- 16.1.1.6. Specifying a Default Button
- 16.1.1.7. Specifying a Cancel Button
- 16.1.1.8. Adding a Title
- 16.1.1.9. Showing Icons in Dialog Boxes
- 16.1.1.10. Using an Icon File in a Dialog Box
- 16.1.1.11. Getting Text Input from the User
- 16.1.1.12. Creating Password Dialog Boxes
- 16.1.1.13. Dismissing Dialogs Automatically
- 16.1.1.14. Validating User-Entered Text
- 16.1.2. Introducing the display alert Command
- 16.1.3. Introducing the choose from list Command
-
16.1.1. Introducing the display dialog Command
-
16.2. Choosing Files, Folders, and Disks
-
16.2.1. Introducing the choose file Command
- 16.2.1.1. From the Dictionary: choose file
- 16.2.1.2. Getting the Results of the Command
- 16.2.1.3. Figuring Out When to Use the Command
- 16.2.1.4. Using the Basic Command
- 16.2.1.5. Creating a Custom Prompt
- 16.2.1.6. Restricting to Specific File Types
- 16.2.1.7. Setting the Default Location
- 16.2.1.8. Picking Invisibles
- 16.2.1.9. Allowing Multiple Selections
- 16.2.1.10. Showing Package Contents
-
16.2.2. Introducing the choose file name Command
- 16.2.2.1. From the Dictionary: choose file name
- 16.2.2.2. choose file name vs. choose file
- 16.2.2.3. Figuring Out When to Use the Command
- 16.2.2.4. Getting the Results of the Command
- 16.2.2.5. Using the Basic Command
- 16.2.2.6. Creating a Custom Prompt
- 16.2.2.7. Setting a Default Name and Location
- 16.2.2.8. Replacing an Existing File
- 16.2.2.9. Seeing an Example in Action
- 16.2.3. Introducing the choose folder Command
-
16.2.1. Introducing the choose file Command
- 16.3. Choosing Other Types of Items
- 16.4. Summary
-
16.1. Creating Basic Dialog Boxes and Gathering Text Input
-
17. Working with Files
- 17.1. Identifying Files, Folders, and Disks
-
17.2. Reading and Writing Files
- 17.2.1. Commands for Reading and Writing Files
- 17.2.2. Dealing with Text File Encodings
- 17.3. Summary
-
18. Organizing Your Code with Handlers
- 18.1. What Are User-Defined Handlers?
- 18.2. Creating a Simple Handler
- 18.3. Using Parameters
- 18.4. What's the Result?
- 18.5. Specifying Handler Parameters
- 18.6. Introducing Recursion
- 18.7. Using the run Handler in Scripts
- 18.8. Working with Handlers in Applets
- 18.9. Tips for Designing and Using Handlers
- 18.10. Example Project: A Reusable Associative List
- 18.11. Summary
- 19. Organizing Your Code with Script Objects
-
3. Putting AppleScript to Work
-
20. Scripting the File System
- 20.1. How the Finder Represents the Mac OS X File System
- 20.2. How System Events Represents the Mac OS X File System
-
20.3. Working with Finder Items
- 20.3.1. Opening and Closing Items
- 20.3.2. Duplicating Files and Folders
- 20.3.3. Deleting Files and Folders
- 20.3.4. Moving Files and Folders
- 20.3.5. Checking if Items Exist
- 20.3.6. Making New Items
- 20.3.7. Sorting Lists of Finder References
- 20.3.8. Ejecting Disks
- 20.3.9. Selecting Items in a Finder Window
- 20.3.10. Converting Finder References to AppleScript Aliases
- 20.4. More on Working with Folders
- 20.5. Locating Important Files and Folders with Standard Additions
- 20.6. Mounting Volumes
- 20.7. Summary
- 21. Scripting Apple Applications
-
22. Extending AppleScript with Scripting Additions
- 22.1. Introducing Scripting Additions and Scriptable Faceless Background Applications
- 22.2. Scripting Additions in Detail
- 22.3. Understanding Scriptable Faceless Background Applications
- 22.4. Examples of AppleScript Extensions
- 22.5. Using the Standard Additions Scripting Addition
- 22.6. Using the Image Events Faceless Background Application
-
22.7. Processing Text with the Satimage Scripting Addition
- 22.7.1. Downloading and Installing the Satimage Scripting Addition
- 22.7.2. Performing Simple Find and Replace Tasks
- 22.7.3. Counting Occurrences of a Substring in a String
- 22.7.4. Finding and Replacing Substrings in a File
- 22.7.5. Searching and Replacing Across Many Files
- 22.7.6. Finding and Replacing Text with Regular Expressions
- 22.7.7. Batch-Changing File Names
- 22.8. Summary
-
23. AppleScript Amenities
- 23.1. Using the Services Menu
- 23.2. Scheduling Scripts with iCal
- 23.3. Triggering Scripts with Folder Actions
- 23.4. Controlling Applications with GUI Scripting
- 23.5. Working with the Clipboard
- 23.6. Summary
-
24. Scripting iWork and Office
- 24.1. Scripting iWork
- 24.2. Scripting Microsoft Office
- 24.3. Summary
- 25. Scripting Data and Databases
-
26. Scripting Adobe InDesign
- 26.1. Learning by Example
- 26.2. Understanding the InDesign Object Model
- 26.3. Working with Documents
- 26.4. Working with Text
- 26.5. Working with Graphics
- 26.6. Drawing Lines
- 26.7. Example Project: An InDesign Scripts Launcher
- 26.8. Working with Tables
- 26.9. Working with Selections
- 26.10. Labeling Objects for Use in Workflow Scripts
- 26.11. Taking Advantage of AppleScript-Specific Preferences
- 26.12. Example Project: Replacing Tags with Images
- 26.13. Using InDesign on a Server
- 26.14. Summary
-
27. Interacting with the Unix Command Line
- 27.1. Why and When Are Shell Scripts Used in AppleScript?
- 27.2. Understanding Unix Scripting Concepts
-
27.3. Running Shell Scripts from AppleScript
- 27.3.1. Scripting the Terminal Application
- 27.3.2. Using the do shell script Command
- 27.3.3. Assembling Shell Script Strings
- 27.3.4. Passing Data to Standard Input
- 27.4. Running AppleScript from Shell Scripts
- 27.5. Example Projects
- 27.6. Summary
- 28. Using Smile: The AppleScript Integrated Production Environment
-
29. Tips and Techniques for Improving Your Scripts
- 29.1. Design, in a Nutshell
- 29.2. Testing and Debugging Your Code
- 29.3. Improving the Performance of Your Code
- 29.4. Summary
-
30. Creating Cocoa Applications with AppleScriptObjC
- 30.1. Example Project: HelloAppleScriptObjC
- 30.2. Understanding How Cocoa Works
- 30.3. Modifying HelloAppleScriptObjC to Set the Text Field
- 30.4. Example Project: PlaySound
- 30.5. Viewing the Cocoa Documentation in Xcode
- 30.6. Example Project: SnapShot
- 30.7. Modifying SnapShot to Use Cocoa Bindings
- 30.8. Modifying PlaySound to Use Bundled Sound Files
- 30.9. Example Project: KitchenTimer
- 30.10. Extra Exercises
- 30.11. Where Next?
- 30.12. Summary
- 30.13. Conclusion
-
20. Scripting the File System
Product information
- Title: Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X, Third Edition
- Author(s):
- Release date: May 2010
- Publisher(s): Apress
- ISBN: 9781430223610
You might also like
book
AppleScript: The Missing Manual
From newspapers to NASA, Mac users around the world use AppleScript to automate their daily computing …
book
Apple Training Series Mac OS X Deployment v10.6: A Guide to Deploying and Maintaining Mac OS X and Mac OS X Software
Apple Training Series: Mac OS X Deployment v10.6 uses a combination of task-based instruction and strong …
book
Apple Pro Training Series: AppleScript 1-2-3
We know what you’re thinking. You’ve heard about AppleScript. You’ve heard that it can do amazing …
book
AppleScript: The Definitive Guide
If you want to know all about AppleScript--the how, where, and why of using it--dig into …