O'Reilly logo

AppleScript® Programming for the Absolute Beginner by Jerry Lee Ford

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

Using Event Handlers to Initiate Action

Using event handlers, you can develop AppleScripts that are capable of reacting to predefined events, like script startup and termination. AppleScript supports a number of different event handlers, including those listed here:

  • run. Automatically executes whenever the AppleScript is run.

  • open. Automatically runs whenever a file, folder, or disk is dragged and dropped onto an AppleScript file.

  • idle. Automatically runs on a periodic basis whenever an AppleScript enters an idle state.

  • quit. Automatically runs when an AppleScript receives a Quit command.

  • reopen. Automatically runs when a docked AppleScript application is reactivated.

    Hint

    Note that when you work with event handlers, you do not include a pair of parentheses ...

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