BY BEN WALDIE

Those who regularly use AppleScript to automate their QuarkXPress-based workflows can attest to the fact that every now and then you may run into a roadblock.

While QuarkXPress' AppleScript support is fairly extensive, unfortunately not every single feature and function is accessible via scripting. In many cases, these limitations pertain to areas that are not commonly automated by the masses. However, since workflows can vary from user to user, these situations are sometimes encountered and when they are, workarounds must be identified.

By no means are AppleScript limitations QuarkXPress specific. Every application's AppleScript support is different, and the level of AppleScript support varies from application to application. Some applications are more scriptable than others, and often, AppleScript developers need to find ways to automate non-scriptable features of various applications. In this article, we are going to discuss just that — how to automate non-scriptable features of QuarkXPress in an AppleScript-based workflow.

User Interface Scripting

User interface scripting, or GUI (Graphical User Interface) scripting, has been used for quite some time as a method of working around non-scriptable features in QuarkXPress and other applications. Back in the days of Mac OS 9 and earlier, perhaps one of the most commonly automated tasks in QuarkXPress that often involved GUI scripting was printing to PostScript. In those days, the option to embed fonts in the produced PostScript file was included in the operating system's print dialogue, which was not directly accessible via scripting. To get around this limitation, AppleScript developers often resorted to a third-party system extension, called PreFab Player. This extension allowed users to write AppleScripts that could click buttons in windows, select check boxes, select from menus, type keystrokes, and more.  Using PreFab Player, an AppleScript could be written to perform various actions that would simulate user interaction, in order to navigate the non-scriptable print dialogues, as if by using an invisible mouse and keyboard.

Today, in Mac OS X, PreFab Player is no longer available. However, Apple has built GUI scripting directly into the operating system. This functionality exists within an AppleScriptable background application in Mac OS X, called System Events. Like PreFab Player in Mac OS 9, System Events will allow an AppleScript to simulate user interaction by clicking buttons, choosing from menus, typing keystrokes, and more.

Enabling GUI Scripting in Mac OS X

By default, GUI scripting in Mac OS X is disabled and it must be turned on in order to use it. To enable GUI scripting, launch the AppleScript Utility application, located in Applications > AppleScript and select the enable GUI scripting check box (see figure 1).

X-Ray Magazine v5n2 Sripting the Non-Scriptable Figure 1

Figure 1 Enabling GUI Scripting Using the AppleScript Utility application.

GUI scripting can also be enabled via Universal Access in the system preferences, by selecting the enable access for assistive devices check box (see figure 2).

X-Ray Magazine v5n2 Sripting the Non-Scriptable Figure 2

Figure 2 Enabling GUI scripting using the Universal Access system preference.

1 | 2 | 3 | 4 | PDF Version

X-Ray Magazine
X-Ray Magazine Logo
X-Ray Magazine
Bookmark and Share
X-Ray Magazine

 

For Email Marketing you can trust