[ Team Lib ] Applescript: the Definitive Guide Explores And
Total Page:16
File Type:pdf, Size:1020Kb
[ Team LiB ] • Table of Contents • Index • Reviews • Reader Reviews • Errata • Academic AppleScript: The Definitive Guide By Matt Neuburg Publisher: O'Reilly Pub Date: November 2003 ISBN: 0-596-00557-1 Pages: 476 AppleScript: The Definitive Guide explores and teaches the language from the ground up. If you're a beginner and want to learn how to write your first script or just understand what the excitement is all about, you'll be able to do so after reading this book. Experienced AppleScripters will love having the most definitive, up-to-date AppleScript language reference available. [ Team LiB ] [ Team LiB ] • Table of Contents • Index • Reviews • Reader Reviews • Errata • Academic AppleScript: The Definitive Guide By Matt Neuburg Publisher: O'Reilly Pub Date: November 2003 ISBN: 0-596-00557-1 Pages: 476 Copyright Preface The Scope of This Book Versions How This Book Is Organized Conventions Used in This Book How to Contact Us Acknowledgments Part I: AppleScript Overview Chapter 1. Ways to Use AppleScript Section 1.1. The Nature and Purpose of AppleScript Section 1.2. Is This Application Scriptable? Section 1.3. Calculation and Repetition Section 1.4. Reduction Section 1.5. Customization Section 1.6. Combining Specialties Chapter 2. Places to Use AppleScript Section 2.1. Script Editor Section 2.2. Scripting Environment Section 2.3. Internally Scriptable Application Section 2.4. Script Runner Section 2.5. Automatic Location Section 2.6. Application Section 2.7. Unix Chapter 3. The AppleScript Experience Section 3.1. The Problem Section 3.2. A Day in the Life Section 3.3. Conclusions, Lessons, and Advice Chapter 4. Basic Concepts Section 4.1. Apple Event Section 4.2. The Open Scripting Architecture Section 4.3. Script Section 4.4. Compiling and Decompiling Section 4.5. Script Text File Section 4.6. Applet and Droplet Section 4.7. Scripting Addition Section 4.8. Dictionary Section 4.9. Scriptable, Recordable, Attachable Part II: The AppleScript Language Chapter 5. Introducing AppleScript Section 5.1. A "Little Language" Section 5.2. Extensibility and Its Perils Section 5.3. The "English-likeness" Monster Section 5.4. Object-likeness Section 5.5. LISP-likeness Section 5.6. The Learning Curve Chapter 6. Syntactic Ground of Being Section 6.1. Lines Section 6.2. Result Section 6.3. Comments Section 6.4. Abbreviations and Synonyms Section 6.5. Blocks Section 6.6. The Chapter 7. Variables Section 7.1. Assignment and Retrieval Section 7.2. Declaration and Definition of Variables Section 7.3. Variable Names Section 7.4. Scoping of Variables Section 7.5. Script Properties Section 7.6. Lifetime of Variables Chapter 8. Handlers Section 8.1. Returned Value Section 8.2. Parameters Section 8.3. Syntax of Defining and Calling a Handler Section 8.4. Pass By Reference Section 8.5. Scoping of Handlers Section 8.6. Handlers as Values Chapter 9. Script Objects Section 9.1. Scoping of Script Objects Section 9.2. Top-Level Entities Section 9.3. Script Object's Run Handler Section 9.4. Handler Calls Section 9.5. Script Objects as Values Section 9.6. Compiled Script Files as Script Objects Section 9.7. Inheritance Chapter 10. Objects Section 10.1. Class Section 10.2. Target Section 10.3. Get Section 10.4. It Section 10.5. Me Section 10.6. Properties and Elements Section 10.7. Element Specifiers Section 10.8. Properties of Multiple References Section 10.9. Object String Specifier Chapter 11. References Section 11.1. References as Incantations Section 11.2. Creating a Reference Section 11.3. Identifying References Section 11.4. Dereferencing a Reference Section 11.5. Creating References to Local Variables Section 11.6. Reference as Parameter Chapter 12. Control Section 12.1. Branching Section 12.2. Looping Section 12.3. Tell Section 12.4. Using Terms From Section 12.5. With Section 12.6. Considering/Ignoring Section 12.7. Errors Section 12.8. Second-Level Evaluation Chapter 13. Datatypes Section 13.1. Boolean Section 13.2. Integer, Real, and Number Section 13.3. Date Section 13.4. String Section 13.5. Unicode Text Section 13.6. Styled Text Section 13.7. File Section 13.8. Alias Section 13.9. Application Section 13.10. Machine Section 13.11. Data Section 13.12. List Section 13.13. Record Chapter 14. Coercions Section 14.1. Implicit Coercion Section 14.2. Explicit Coercion Section 14.3. Boolean Coercions Section 14.4. String, Number and Date Coercions Section 14.5. File Coercions Section 14.6. List Coercions Section 14.7. Unit Conversions Chapter 15. Operators Section 15.1. Arithmetic Operators Section 15.2. Boolean Operators Section 15.3. Comparison Operators Section 15.4. Containment Operators Section 15.5. Concatenation Operator Section 15.6. Parentheses Section 15.7. Who Performs an Operation Chapter 16. Global Properties Section 16.1. Strings Section 16.2. Numbers Section 16.3. Miscellaneous Chapter 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 application responses current application Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday January, February, March, April, May, June, July, August, September, October, November, December Chapter 18. Commands Section 18.1. Application Commands Section 18.2. Logging Commands Part III: AppleScript In Action Chapter 19. Dictionaries Section 19.1. Resolution of Terminology Section 19.2. Resolution Difficulties Section 19.3. What's in a Dictionary Section 19.4. The 'aeut' Resource Section 19.5. Inadequacies of the Dictionary Chapter 20. Scripting Additions Section 20.1. Pros and Cons of Scripting Additions Section 20.2. Scripting Additions and Speed Section 20.3. Classic Scripting Additions Section 20.4. Loading Scripting Additions Section 20.5. Standard Scripting Addition Commands Chapter 21. Scriptable Applications Section 21.1. Targeting Scriptable Applications Section 21.2. Some Scriptable Applications Chapter 22. Unscriptable Applications Section 22.1. Getting Started with Accessibility Section 22.2. GUI Scripting Examples Chapter 23. Unix Section 23.1. Do Shell Script Section 23.2. Osascript Chapter 24. Writing Applications Section 24.1. Applets Section 24.2. Digital Hub Scripting Section 24.3. Folder Actions Section 24.4. CGI Application Section 24.5. AppleScript Studio Part IV: Appendixes Appendix A. The 'aeut' Resource Appendix B. Tools and Resources Section B.1. Scripting Software Section B.2. Other Software Mentioned in This Book Section B.3. Apple Documentation Section B.4. Portals, Instruction, and Repositories Section B.5. Mailing Lists Section B.6. Books Section B.7. Unix Scripting Colophon Index [ Team LiB ] [ Team LiB ] Copyright Copyright © 2004 O'Reilly & Associates, Inc. Printed in the United States of America. Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O'Reilly & Associates books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 [email protected] . Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of ANIMAL and the topic of TOPIC is a trademark of O'Reilly & Associates, Inc. Apple Computer, Inc., boldly combined open source technologies with its own programming efforts to create Mac OS X, one of the most versatile and stable operating systems now available. In the same spirit, Apple has joined forces with O'Reilly & Associates, Inc., to bring you an indispensable collection of technical publications. The ADC logo indicates that the book has been technically reviewed by Apple engineers and is recommended by the Apple Developer Connection. Apple, the Apple logo, AppleScript, AppleScript Studio, AppleTalk, AppleWorks, Aqua, Carbon, Cocoa, ColorSync, Finder, FireWire, iBook, iMac, Inkwell, iPod, .Mac, Mac, Mac logo, Macintosh, PowerBook, QuickTime, QuickTime logo, Rendezvous, and Sherlock are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. The "keyboard" Apple logo ) is used with permission of Apple Computer, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. [ Team LiB ] [ Team LiB ] Preface From a technological and historical perspective, AppleScript is one of the greatest innovations and distinguishing features of the Mac OS. The System provides not only a mechanism for applications to communicate with one another, ordering one another about, getting information from one another, and generally collaborating to avail themselves of one another's strengths and abilities, but also a way for ordinary users to take advantage of this mechanism programmatically. The user can write and execute code in the AppleScript language as a way of automating the behavior of applications, reducing many steps to one, throwing the burden of repetition and calculation onto the computer, and combining the powers of multiple applications into a seamless united workflow. AppleScript is a labor-saving device that lets ordinary users program the computer for themselves; and, after all, labor-saving and programming are just what computers are all about.