For the past several years I have been slowly undertaking the monolithic task of rewriting Permanent Eraser. However, such an endeavor has become quite the Sisyphean task as my efforts have come in random spurts between my various other projects. As an interim option, I looked at adding a new feature to the existing app, such as including AppleScript support (something I've been wanting to include for many, many years).
AppleScript Scriptable Resources
Here's a variety of links I went through on how to make a Mac app scriptable. The first three are the ones which I found the most useful and cut through a lot of the confusion of how to get things set up.
- Making Your Mac App’s Data Scriptable
- Boilerplate to Add AppleScript to Your macOS App in 2020
- Getting Started With Cocoa Scripting
- Making A Mac App Scriptable Tutorial
- How do I add Applescript support to my Cocoa application?
- How to implement AppleScript support in a Swift MacOS app
- Sdef Editor
- Editor for Dictionary Files (.sdef)
- looking for 64bit version of Sdef Editor for M1 Mac
- Overview of Cocoa Support for Scriptable Applications
- Scriptable Applications
When I was doing research about scripting Mac apps, I took a look at other older programs and their AppleScript dictionaries. One of the examples I came across was the stalwart image editor Acorn which has an amusing
taunt command, which results in this fun little dialog to appear:
Here's the AppleScript:
tell application "Acorn" taunt end tell
Permanent Eraser and AppleScript
After some initial experimentation, I was able to finally get AppleScript to communicate with Permanent Eraser. That's the good news, a basic proof of concept showed that it can work. The bad news is that much like when I tried to implement NSServices in Permanent Eraser the poor design choices made back in 2004 prevent it from working well. To get either NSServices or AppleScript to work with Permanent Eraser will require rearchitecting the app, but doing so will move it much closer to what I've hoped to fulfill with Permanent Eraser. While making Permanent Eraser 2 scriptable is not feasible at the moment, it has been quite an interesting and rewarding trip down another rabbit hole.