Chapter 26. Triggering Scripts Automatically
What causes a script to run? It might be that you deliberately run it—you press the Run button in a script editor application, for example, or you choose the script from the menu of a script runner environment. However, there is a whole class of situations where your script just sits there patiently and eventually some other process comes along and runs it, with no direct intervention or action on your part. I call this sort of milieu an automatic location (see Chapter 2). In an automatic location, AppleScript takes a passive instead of an active part. Instead of you personally setting a chain of events in motion, AppleScript operates in response to other events or activities taking place on your computer: someone inserts an audio CD, someone moves a file into a certain folder, a certain web page request appears at your server, a certain time of day arrives, the computer wakes from sleep, a certain hard drive is mounted, the telephone rings.
There are a number of distinct automatic locations built into Tiger, and there are many varieties of circumstance in which third-party applications may trigger your scripts. A complete compendium of the ways in which scripts can be triggered automatically would be impossible, so the chief purpose of this chapter is to awaken you to the range of possibilities. You may be surprised by the sorts of role AppleScript can play on your computer.
Preparing a script to operate in an automatic location is different ...
Get AppleScript: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.