Modernising Power Manager's AppleScript
We revisited AppleScript support and gained a terminology reference.
Power Manager has included support for AppleScript for well over a decade. Recently we revisited the code that underpins AppleScript support and modernised it.
Writing the original implementation of AppleScript for Power Manager felt like summiting a mountain. The time spent fitting together the demands of AppleScript and the design of Power Manager was gruelling, to say the least. Eventually we found a way to make it work and make it robust. That moment, the moment when we knew the approach was going to succeed, felt wonderful.
That was around 2007. With the launch of v3.5, Power Manager’s scripting support jumped from basic to complete. Every request and response, every class and structure, became accessible via AppleScript.
Having AppleScript has proven worthwhile time and time again. Personally, I appreciate scripting for its role in technical support. With short scripts, I have been able to help customers craft complex events, automate settings, and simplify deployments.
In one instance, a customer’s need was solved with a single event containing over one hundred triggers. That event pushed my expectations of what was reasonable but it worked. Creating such large events by hand is possible but unreasonably time consuming. With an AppleScript it was not only easy but possible to test, refine, and recreate.
Aware of how complex the code implementing AppleScript was, we have largely avoided major changes. That is until recently.
In the last months Power Manager’s AppleScript code has been modernised. We revisited the code with a decade of use and experience to draw upon. The result is reassuringly better and more refined.
Outwardly the modernised AppleScript support should be almost undetectable. That was our intention. Your AppleScripts will continue to run without change or recompilation.
A few AppleScript bugs were found and fixed but thankfully nothing dramatic. The next release of Power Manager will include this new AppleScript implementation and the release notes will mention the change.
The reason I mention this modernisation, before it is published, is because the work produced a welcome side effect. I have been able to create a reference page of Power Manager’s scripting terminology. The terminology has always been visible through macOS’s Script Editor.app (formally AppleScript Editor.app) but it has never before been published on the web.
With this published reference, we can now link directly to classes and commands in recipes and our support e-mails.
If you are interested in learning more about AppleScript, we have a collection of sample scripts in the Power Manager: AppleScript guide.