AppleScript in a Nutshell

Book description

AppleScript in a Nutshell is the first complete reference to AppleScript, the popular programming language that gives both power users and sophisticated enterprise customers the important ability to automate repetitive tasks and customize applications. As the Macintosh continues to expand and solidify its base in the multimedia and publishing industries, AppleScript is the tool of choice on this platform for creating sophisticated time- and money-saving workflow applications (applets). These applets automate the processing and management of digital video, imaging, print, and web-based material. AppleScript is also gaining a foothold in scientific programming, as technical organizations adopt G4 CPU-based systems for advanced computing and scientific analysis. Finally, "power users" and script novices will find that AppleScript is a great everyday Mac programming tool, similar to Perl on Windows NT or Unix.In this well-organized and concise reference, AppleScript programmers will find:

  • Detailed coverage of AppleScript Version 1.4 and beyond on Mac OS 9 and Mac OS X.
  • Complete descriptions of AppleScript language features, such as data types, flow-control statements, functions, object-oriented features (script objects and libraries), and other syntactical elements.
  • Descriptions and hundreds of code samples on programming the various "scriptable" system components, such as the Finder, File Sharing, File Exchange, Network scripting, Web scripting, Apple System Profiler, the ColorSync program, and the numerous powerful language extensions called "osax" or scripting additions.Most other AppleScript books are hopelessly out of date. AppleScript in a Nutshell covers the latest updates and improvements with practical, easy to understand tips, including:
  • Using AppleScript as a tool for distributed computing, an exciting development that Apple Computer calls "program linking over IP." Programmers can now do distributed computing with Macs over TCP/IP networks, including controlling remote applications with AppleScript and calling AppleScript methods on code libraries that are located on other machines.
  • Using the Sherlock find application to automate web and network searching.
  • Insights on scripting new Apple technologies such as Apple Data Detectors, Folder Actions, Keychain Access, and Apple Verifier.AppleScript in a Nutshell is a high-end handbook at a low-end price--an essential desktop reference that puts the full power of this user-friendly programming language into every AppleScript user's hands.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2. Preface
    1. Organization of This Book
      1. Part I
        1. Chapter 1
        2. Chapter 2
      2. Part II
        1. Chapter 3
        2. Chapter 4
        3. Chapter 5
        4. Chapter 6
        5. Chapter 7
        6. Chapter 8
        7. Chapter 9
      3. Part III
        1. Chapter 10
        2. Chapter 11
        3. Chapter 12
        4. Chapter 13
        5. Chapter 14
        6. Chapter 15
        7. Chapter 16
        8. Chapter 17
        9. Chapter 18
      4. Part IV
        1. Chapter 19
        2. Chapter 20
        3. Chapter 21
        4. Chapter 22
        5. Chapter 23
        6. Chapter 24
        7. Chapter 25
        8. Chapter 26
        9. Chapter 27
        10. Chapter 28
        11. Chapter 29
        12. Chapter 30
        13. Chapter 31
      5. Part V
        1. Chapter 32
        2. Chapter 33
        3. Chapter 34
        4. Chapter 35
      6. Part VI
        1. Appendix A
        2. Appendix B
    2. Conventions Used in This Book
    3. How to Contact Us
    4. Acknowledgments
  3. I. Introduction to AppleScript
    1. 1. AppleScript: An Introduction
      1. How Is AppleScript Used?
        1. Automation
        2. Attachability/Recordability
        3. Scripting Additions
      2. Apple Events
        1. OSA
        2. Apple Event Registry
        3. Client/Server
        4. Inside an Apple Event
        5. Apple Event Parameters
        6. Apple Event Classes and Objects
        7. Elements and Properties
        8. Application Class
      3. Using Script Runner with OS X
      4. Using OSA Menu with OS 9
      5. Checking Your AppleScript Version
      6. Diving In
        1. Case Sensitivity
        2. Statement Termination
        3. Line Continuation Character
        4. Naming Identifiers or Variables and Functions
        5. Variable Declaration
        6. Comments
        7. Data Types
        8. Operators and Reference Forms
        9. Flow-Control Statements
        10. Subroutines
        11. Script Objects
    2. 2. Using Script Editor with OS 9 and OS X
      1. Script Editor Controls/Commands
        1. Dictionaries
        2. Special Edit Menu Items
        3. Script Saving Options
          1. Script text file
          2. Compiled script file
          3. Classic applet
          4. MacOS X applets
          5. Applets versus droplets
        4. Debugging with Event Log and Result Windows
          1. Event Log
          2. Result window
      2. Scripting the Script Editor
  4. II. AppleScript Language Reference
    1. 3. Data Types
      1. alias
      2. boolean
      3. class
      4. constant
      5. data
      6. date
      7. file specification
      8. integer
      9. international text
      10. list
      11. number
      12. real
      13. record
      14. reference
      15. RGB color
      16. string
      17. Styled Clipboard Text
      18. Styled Text
      19. text
      20. Unicode Text
      21. Unit of Measurement Classes
    2. 4. Operators
      1. &
      2. ( )
      3. *
      4. +
      5. -
      6. / ÷ div
      7. <
      8. ≤ <=
      9. =
      10. >
      11. ≥ >=
      12. ^
      13. [a] reference to
      14. and
      15. as
      16. begin[s] with
      17. contains
      18. does not contain
      19. does not equal
      20. ends with
      21. is contained by
      22. is not contained by
      23. mod
      24. not
      25. or
    3. 5. Reference Forms
      1. after
      2. back
      3. before
      4. beginning
      5. first, second, third, fourth, etc.
      6. every
      7. every ... from ... to ...
      8. id
      9. last
      10. middle
      11. name
      12. some
      13. whose
    4. 6. Variables and Constants
      1. Variables
        1. Variable Scope
        2. Properties
      2. Constants and Predefined Variables
    5. 7. Flow-Control Statements
      1. considering [but ignoring] end [considering]
      2. continue
      3. error
      4. exit [repeat]
      5. if simple statement
      6. if [then] [else if] [else] end [if]
      7. ignoring [but considering] end [ignoring]
      8. repeat end [repeat]
      9. repeat until end [repeat]
      10. repeat while end [repeat]
      11. repeat with {loop variable} from {integer} to {integer}[by stepVal] end [repeat]
      12. repeat with {loop variable} in {list} end [repeat]
      13. repeat {integer} times end [repeat]
      14. return [return value]
      15. tell simple statement
      16. tell end [tell]
      17. try [on error] [number | from | partial result | to] end[error | try]
      18. using terms from end [using terms from]
      19. with timeout [of] {integer} second[s] end [timeout]
      20. with transaction [session object] end [transaction]
    6. 8. Subroutines
      1. Subroutines with Positional Parameters
      2. Subroutines with Labeled Parameters
    7. 9. Script Objects and Libraries
      1. Script Objects
      2. Libraries
  5. III. Scripting Mac OS 9 Applications
    1. 10. Apple Guide and Help Viewer
      1. Apple Guide
      2. Help Viewer
    2. 11. Apple System Profiler
      1. Apple System Profiler
    3. 12. Keychain Scripting and Apple Verifier
      1. Keychain Scripting
      2. Apple Verifier
    4. 13. Desktop Printer Manager
      1. Desktop Print Manager
    5. 14. Mac OS 9 Finder Commands
      1. Example Finder Scripts
        1. Finding Out the Operating System Version
        2. Displaying the File and Creator Types of Files
        3. Finding and Deleting Only Certain File Types
        4. Displaying the Free Space of Each Disk
        5. Displaying the Running Processes in a list Box and Optionally Closing Some of Them
    6. 15. Mac OS 9 Finder Classes
      1. Finder Classes
    7. 16. Network Setup Scripting
      1. Network Setup Scripting
    8. 17. Scripting Sherlock 2
      1. Sherlock 2
    9. 18. URL Access Scripting
      1. URL Access Scripting
  6. IV. Scripting Mac OS 9 Control Panels and Extensions
    1. 19. Appearance Control Panel
      1. Appearance Control Panel
    2. 20. Apple Data Detectors Extension
      1. Apple Data Detectors
    3. 21. Apple Menu Options Control Panel
      1. Apple Menu Options
    4. 22. Application Switcher Extension
      1. Application Switcher
    5. 23. ColorSync Extension
      1. ColorSync
    6. 24. File Exchange Control Panel
      1. File Exchange
    7. 25. File Sharing Control Panel
      1. File Sharing
    8. 26. Folder Actions Extension
      1. Folder Actions
    9. 27. FontSync Control Panel and Extension
      1. FontSync Control Panel
      2. FontSync Extension
    10. 28. Location Manager Control Panel
      1. Location Manager
    11. 29. Memory and Mouse Control Panels
      1. Memory Control Panel
      2. Mouse Control Panel
    12. 30. Speech Listener and SpeakableItems Extension
      1. Speech Listener Application
      2. SpeakableItems Extension
      3. Embedded Speech Commands
    13. 31. Web Sharing Control Panel
  7. V. Scripting the Mac OS X System
    1. 32. Scripting the OS X Desktop
      1. Working with Files, Folders, Disks, and Windows in OS X
        1. Making New Files and Folders
        2. Working with Finder and Inspector Windows
        3. A Work in Progress
    2. 33. Scripting Mail
      1. Setting Up an Email Message
      2. Exploring the Mail Application Object
      3. Getting Information about an Email Account
    3. 34. Executing Scripts with the Terminal App
      1. osacompile
      2. osalang
      3. osascript
    4. 35. Scripting TextEdit
      1. TextEdit
  8. VI. Appendixes
    1. A. Standard Scripting Additions
      1. Standard Additions
      2. Standard Additions
    2. B. AppleScript Resources
      1. Apple Computer AppleScript URLs
      2. AppleScript FAQs, Mailing Lists, and Tutorials
      3. Macintosh Scripting Sites
      4. Commercial AppleScript Development Environments
      5. Freeware AppleScript Development Environments
  9. Index
  10. About the Author
  11. Colophon
  12. Copyright

Product information

  • Title: AppleScript in a Nutshell
  • Author(s): Bruce W. Perry
  • Release date: June 2001
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565928411