Chapter 22. Unscriptable Applications

Some applications are not scriptable; they have no repertory of Apple events to which they are prepared to respond. The developers simply omitted this feature, like the tinsmith who forgot to give the Woodsman a heart. You try to open the application’s dictionary and you get an error. Other applications are scriptable, but they aren’t scriptable in the way you’d like; the thing you’d like to make the application do isn’t among its scriptable behaviors. In a case like this, how can you script the unscriptable?

On Mac OS 9 and before, the answer was to use a macro program . A macro program has the power to “see” an application’s interface and to act as a kind of ghost user, pressing buttons, typing keys, and choosing menu items. Anything a user can do in an application can presumably be performed through some definable sequence of mouse and keyboard gestures; therefore it might be possible to emulate that sequence of gestures with a macro program. The result might not be as fast, elegant, or flexible as using AppleScript, but it could get the job done; plus, a macro program might itself be scriptable. (Three very strong macro programs that I often used on earlier System versions were QuicKeys, PreFab Player, and OneClick; see http://www.cesoft.com/products/qkmac.html, http://www.prefab.com/player.html, and http://www.westcodesoft.com/index.html.)

In the past, macro programs depended upon a feature of the System architecture whereby third-party ...

Get AppleScript: The Definitive Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.