Application

By application I mean here an application you write yourself. There are various ways to incorporate use of AppleScript into an application, and various reasons why you might do so.

Let’s start with an applet. An applet is just a compiled script saved with a tiny application framework wrapped around it; you can make one in any script editor application. I can think of three main reasons for saving a script as an applet:

  • You want to be able to run the script from the Finder, by double-clicking it.

  • You want your script to process files and folders when you drop their icons onto the script’s icon; an applet that does is this called a droplet .

  • You want to be able to run the script from some other environment that can launch things but isn’t a script runner.

We have already seen that if you want a script to be a Startup Item, so that it runs automatically at startup, it has to be an applet. As another example, consider the toolbar and sidebar at the top and left side of a Finder window. You can put any item you like in these places; clicking an item opens it, in the sense of launching it, as if from the Finder. So items in the toolbar or sidebar cannot be mere compiled scripts if you want to run them; they must be applets (or droplets—dropping a file or folder onto a toolbar or sidebar droplet works just fine). Apple supplies a number of examples at http://www.apple.com/applescript/toolbar/.

Moving up the ladder of complexity and sophistication, we arrive at another way you ...

Get AppleScript: The Definitive Guide 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.