Chapter 28. AppleScript

AppleScript is a language designed to allow normal users to automate repetitious tasks. When an AppleScript script is run, it usually generates some Apple events. Apple events move between applications by way of the Apple event manager and mach messaging.

You can create and run AppleScript scripts using the application /Applications/ AppleScript/Script Editor. The following simple script will bring up a new document containing the words “Share the love” in TextEdit. Type it into Script Editor and try it out:

tell application "TextEdit"
      activate
      make new document at the beginning of documents
      set the text of the front document to "Share the love"
end tell

As a programmer, I find the AppleScript language to be rather strange ...

Get COCOA PROGRAMMING FOR MAC OS X SECOND EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.