10.4. Applets and Droplets

You learned how to save an AppleScript program as an application in Chapter 3. Programs that are saved this way are called applets (although we use this term interchangeably with the term application here). They otherwise behave as normal applications: You can double-click them to launch them. You can also make them Run Only to prevent them from being opened and their code examined. If you save an application with the Run Only box checked, even you can no longer open the file and edit it in Script Editor. Therefore, you want to be sure to make a copy of your program before you save it as a Run Only application.

10.4.1. Stay Open Applications

If you check Script Editor's Stay Open option when you save your program as an application, the program does not quit when it has finished executing. Instead, it stays active or open. That's like launching the Finder. Even after you close the last Finder window, the application stays open, as you can tell just by looking at the Finder's icon in your Dock. (The little black triangle underneath the application's icon in the Dock tells you the application is active.) Keeping an application active can save time the next time you want to use it because it doesn't have to be reinitialized.

A Stay Open application can have an idle handler (described shortly). This handler is called automatically at specified intervals. The reopen handler is also useful in combination with Stay Open handlers. That too, is described in an ...

Get Beginning AppleScript® 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.