IN THIS CHAPTER
What are applets?
What are droplets?
In Chapter 11, you learned how to create reusable subroutines. Learning how to work with subroutines marks a serious step forward, as it allows you to code smarter and create reusable automation solutions.
In this chapter, you're going to take your knowledge one step further and learn how to create applets and droplets. As you'll see, applets and droplets are both very simple to comprehend, but open you up to a whole new world of possibilities in your scripting.
An applet is an application with a minimal user interface that nonetheless stands alone. It has its own icon and can be double-clicked to make its code run. It doesn't need to run inside of the Script Editor, which is what you've been doing so far in this book. The reason why it can run standalone is because an applet contains some compiled bootstrap code inside it that allows it to run in that fashion.
Just about any AppleScript you create can be turned into an applet. There's really no difference between a simple script that contains say "
hello" and an applet with the same code, except that the applet can run by itself when you double-click its icon.
Creating an applet is extremely simple and requires only two rules (and even one of these rules is optional):
First, you should encapsulate your code in an
on run statement. This isn't necessary, as the
run command is implied, but it's good practice.