Chapter 24. Unscriptable ApplicationsSome 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. Other applications are scriptable, but not in the way you'd like; the thing you'd like to make the application do isn't among its scriptable behaviors. How can you script the unscriptable ? In theory, of course, you can't, and this book shouldn't be discussing this situation at all. AppleScript is about talking to applications with Apple events, and these applications are refusing to listen. It turns out, however, that in many cases you can use AppleScript in a different way, to direct simulated user actions at an unscriptable application. If you can do something with the mouse and keyboard, you may be able to automate those same mouse and keyboard movements using AppleScript, by means of a technology called GUI scripting . When you use GUI scripting, you are essentially driving a a macro program that functions as an intermediary between AppleScript and the target application. Such a 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 true scripting by means of Apple events, but might get the job done. The macro program used here will be System Events (see Chapter 23). |