As I’ve previously mentioned, UltraPaint and artWORKS share a lot of DNA so their structure is effectively identical, including the tool palette. This is a good thing as I intend to automate tool selection in both apps and I’ll take any help 30-year-old software wants to send my way!
Chapter 6 in the book “The Automatic Mac” (1992, download) details a number of ways of scripting graphics programs. They use Canvas as an example, which is great because that is a very close relative to the artWORKS and UltraPaint apps that I use. The book informed a lot of what I’m doing here, though my approach differs because of my available tools and personal preference.
My first thought was to try the naive way of selecting tools by just clicking them! If the tool palettes are positioned in the same place (this can also be automated) then macros can simply click at specific screen locations to select a tool. This approach works well for both apps. But this is a very fragile way of automating interactions—if windows are inadvertently moved the automation will break. So, there’s definitely room for improvement.
The interapplication communication (IAC) architecture provides a standard and extensible mechanism for communication among Macintosh applications. The IAC architecture makes it possible for your application to
- provide automated copy and paste operations between your application and other applications
- be manipulated by means of scripts
- send and respond to Apple events
- send and respond to high-level events other than Apple events
- read and write blocks of data between applications
Sounds perfect—my idea of a good time!
To support AppleScript, apps were required to offer suites of supported messages and mechanisms. These are advertised through the
aete resource. ResEdit shows this data as raw hex, unless you install a template to enable it to make sense of it. Resorcerer supports it out of the box. There are a bunch of other tools that can display the data in a human readable way such an Apple-created HyperCard stack, a third-party app called EightyRez, and automation tool QuicKeys to name just a few.
QuicKeys sounded ideal as it lets me query the data, using a set of dropdown menus, and use it to specify automation to try out the Apple Events way of selecting a tool. It worked first time! But it was slow, and there was a distracting loss of window focus as the macro was executed.
In search of something better turned to my favourite classic automation tool: KeyQuencer. I’d previously searched trough various archives for any available macros, so had a vague memory there was something out there I might be able to use. I dug up AESend, an Apple Events extension for KeyQuencer.
I used QuicKeys GUI to set up the initial Apple Events call, as it allows you to pick options from drop-down lists. Then I used the Capture AE control panel to decode the Apple Events call into something human readable that I could adapt for use in KeyQuencer. I’d still take that approach for any new Apple Events.
The result was much faster Apple Events sending and no distracting window focus flickering.
The end result is a macro of two parts: the first section operates artWORKS using Apple Events, continuing without complaint if the app is not open, and the second section operates UltraPaint using simple mouse clicks.
I plan to adding support for Canvas 3.x at some point as this shares Apple Events support with artWORKS.
According to the
aete resource description in both artWORKS and Canvas, selection of Internal Tools using Apple Events is limited to 10 seemingly random tools. This made no sense to me, so I tried specifying higher tools and this experimentation proved that all 18 internal tools are indeed available. I guess the description had been truncated at some point?
Some time later I read “The Automatic Mac” again and it shows a more complete list of tool values! The order seems to be based on the tool palette in Canvas.
Even so, I went the extra mile to complete a list of both internal and external tools, shown below.
Internal Tools (btol)
|Paint Object Creator||18|
External Tools (etol)
- Turning an iPad Pro into the Ultimate Classic Macintosh
- How to install BasiliskII on your iPad
- Exploring Custom Keyboards and Automation
- Optimising Macintosh app toolbars for touch
- Macintosh drawing software compared
- Mixing External Tools across Deneba software
- My System 7 software choices
- About the interoperability of System 7 and iOS