I have recently came across several amazingly useful libraries for MacOS tasks automation with AppleScript. Even though they exists for several years now, for a long time I had no idea these existed. So I’ve decided to share my discovery here and hope it will help somebody in the future.
AppleScript automation on MacOS
AppleScript is, like the name suggests, a scripting language used mainly on MacOS platform. It allows various tasks automation in a variety of ways. It’s very powerful, yet has several limitations. In particular I have been recently blocked by two AppleScript’s limitations: Calendar events searching and dialog box configurations.
It turned out that performing several Calendar tasks using AppleScript is unexpectedly (at least for me) slow. So slow in fact, that it becomes practically unusable. In my case searching for an event in a given calendar, meeting certain criteria (start and end date) took almost an hour. That was simply not acceptable.
I’ve also discovered (to my surprise) that the default display dialog
command limits the dialog window appearance to just labels, optional list box and up to two buttons. Whereas I’ve needed to display a dialog window containing checkboxes. And what’s worse – the number of checkboxes depended on some variable value. So I needed a way to create a dialog window that could contain a label, two buttons and anything between 1 and let’s say 40 checkboxes.
Shane Stanley’s AppleScript Libraries
While looking for ways to solve those issues, I’ve came across some a couple of brilliant AppleScript Libraries created by Shane Stanley. Particularly interesting for me were CalendarLib EC and Dialog Toolkit Plus.
The Dialog Toolkit Plus library enables us to generate a lot more complex dialog windows than standard AppleScript. Like you can see above, we can add radio buttons, checkboxes, path controls, popup menus and a lot more.
The CalendarLib EC library enables us to perform operations (add, modify, etc.) on calendar events without using the Calendar.app. And because of this, it’s lightning fast compared to using Calendar.app with AppleScript. It also includes recurring events.
You can download both (and many more) from the link above. In order to use them, simply create a directory named Script Libraries in the Libraries directory (if not already created) and paste the downloaded .scptd files there.