O'Reilly logo

COCOA PROGRAMMING FOR MAC OS X SECOND EDITION by Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required