Apress

Learn AppleScript

The Comprehensive Guide to Scripting and Automation on Mac OS X

3rd Edition

By Hamish Sanderson , Hanaan Rosenthal

Learn AppleScript Cover Image

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.

Full Description

  • ISBN13: 978-1-4302-2361-0
  • User Level: Beginner to Advanced
  • Publication Date: May 4, 2010
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $49.99
  • eBook Price: $34.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

AppleScript is an English-like, easy-to-understand scripting language built into every Mac. AppleScript can automate hundreds of AppleScript-able 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

What you’ll learn

  • See how AppleScript represents information as objects—including numbers, strings, lists, and records.
  • Learn how to manipulate these objects using commands and operators, and how to store them in variables.
  • Organize your code using handlers and script objects.
  • Understand how applications describe their objects and commands in dictionaries and how to interpret that information when learning to script applications.
  • Manipulate the Mac OS X file system.
  • Automate iTunes, Mail, iCal, and other popular lifestyle applications in Mac OS X.
  • Discover sophisticated text processing techniques using regular expressions.
  • Script professional productivity applications—Apple iWork, Microsoft Office, FileMaker Pro, and Adobe InDesign.
  • Harness the power of the Unix command line in Mac OS X.
  • Create your own Cocoa applications with the new AppleScriptObjC bridge.

Who this book is for

  • First-time scripters who want to automate tasks on their Macs
  • Existing AppleScripters looking to develop proficient, professional, or guru-level knowledge and skills
  • Professional Mac OS X developers wishing to understand this powerful and pervasive technology

Table of Contents

Table of Contents

  1. Introducing AppleScript
  2. AppleScript in Principle
  3. AppleScript in Practice
  4. Writing Scripts in AppleScript Editor
  5. Understanding How Application Scripting Works
  6. Learning to Work with AppleScript Objects
  7. Working with Text
  8. Working with Numbers
  9. Working with Dates
  10. Working with Lists and Records
  11. Storing Objects in Variables
  12. More on Commands
  13. More on Operators and Coercions
  14. Making Decisions Using Conditionals and Loops
  15. Making Decisions When Dealing with Errors
  16. Interacting with the User
  17. Working with Files
  18. Organizing Your Code with Handlers
  19. Organizing Your Code with Script Objects
  20. Scripting the File System
  21. Scripting Apple Applications
  22. Extending AppleScript with Scripting Additions
  23. AppleScript Amenities
  24. Scripting iWork and Office
  25. Scripting Data and Databases
  26. Scripting Adobe InDesign
  27. Interacting with the Unix Command Line
  28. Using Smile: The AppleScript Integrated Production Environment
  29. Tips and Techniques for Improving Your Scripts
  30. Creating Cocoa Applications with AppleScriptObjC
Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

If you think that you've found an error in this book, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.

* Required Fields

On page Script 18-22:

In the example on associative lists, the handler delete_associative_item() does not work in Mac OS X Lion. The statement "set contents of record_ref to missing value" fails. Even when using an item number instead of a record reference, it fails. The corresponding example in Chapter 19 also fails.

Was there a change in AppleScript under Lion which prevents modifying an entire item?

On page 220:
Corrected script. names are shortened.

set total_post to 27
set post_per to 4
set whole_page to total_post div post_per
if total_post mod post_per ≠ 0 then
set whole_page to whole_page + 1
end if
return whole_page

The "if" statement is incorrect. should be "total post mod" and not "whole page mod".

On page 557:
final paragraph, bottom of page 557 -- ''.... Well, in Chapter 10 the original associative list design was mixed together with the...'' -- can find no reference there -- all about word counting