Quark UI Scripting

Has anyone had any luck with UI scripting the print dialog in QuarkXPress 6.1, 6.5 on OSX 10.3???

I have a script where I want to select the “Preview” tab from the print dialog window. Selecting the Preview tab isn’t the issue. Its that the options that appear below that tab group don’t update unless I acutally click the tab with my mouse. The script below selects the “Preview” tab but it will not show the additional options that are usually in the center of the Print Dialog.

activate application "QuarkXPress"
tell application "System Events"
	tell process "QuarkXPress"
		
		if title of window 1 contains "Print" then
			
set window_name to name of window 1
			perform action "AXPress" of radio button "Preview" of tab group 1 of window window_name
			
			
		end if
	end tell
end tell

After running the above script, the preview is selected, but doesn’t update the options portion of the print window until I click the preview tab again with my mouse. This led me to try adding these lines below the first “perform action line”. I’ve also tried a number of variations on this with no success.

delay 2
			activate
			perform action "AXPress" of radio button "Preview" of tab group 1 of window window_name
			try
				-- modify offsets as needed for hot spot
				tell radio button "Preview" of tab group 1 of window window_name
					set pos to position as list
					set siz to size as list
					set x to item 1 of pos
					set y to item 2 of pos
					set width to item 1 of siz
					set height to item 2 of siz
					click at {x + width / 2, y + height / 2}
				end tell
			end try

Model: G5
AppleScript: Not sure
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.3.9)

You may be better off using regular AS to set the print parameters and then the UI bit only to perform the send to print part. Quark 6 & Tiger for some reason can’t handle a scripted print command right now, so UI is your only option for the last bit. However, you may be able to set print parameters first and then go to UI. Something like what’s below though what’s below is set up to export to PDF rather than print. Let me know if you get anywhere. Also, see the following discussion on the Quark AS forum for more info: http://www.quark.com/service/forums/viewtopic.php?t=8016


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thank you for responding.

I actually am using UI Actions to run an AS script when the user opens the print dialog. I set all the print parameters with AS but wanted to show the Graphic Designers a prevew of their document. Thank you for your help. Anymore guidance would be appreciated!

Matt

Sorry, but is it only me who keep getting "“NSReceiverEvaluationScriptError: 4” as soon as I try to get system events to click buttons in QuarkXpress passport (6.5), and if I don’t get that, it clicks the button (you can visualy see it happening) but too “softly” :wink: that is: no responce…

Anyone who knows how too click harder on buttons? :wink: (seriously ment as a question though)

Regards / Johan

I don’t use Quark myself - but, if you have to use GUI scripting and all else fails (until these issues are resolved), you might consider trying Extra Suites, which is a background scripting application that may do what you want. It’s reasonably priced and you can try it out before buying.

This should demonstrate how to click another UI element that has proved notoriously elusive in terms of UI access: the PDF button in a Cocoa app’s standard print dialog. (It should save the front document of the targeted app to the desktop as a PDF file):

Requires Extra Suites:

to |click mouse| at p
	tell application "Extra Suites"
		ES move mouse p
		ES click mouse
	end tell
end |click mouse|

to |save front doc as PDF| to file_name from app_name
	tell application "System Events" to tell process app_name
		set frontmost to true
		keystroke "p" using command down
		tell UI element -1 of UI element -1 of UI element -5 of sheet 1 of window 1
			repeat until exists
				delay 0.1
			end repeat
			|click mouse| of me at position
		end tell
		key code {125, 36}
		repeat until window "Save" exists
			delay 0.1
		end repeat
		keystroke file_name
		keystroke "ds" using command down (* save to desktop *)
	end tell
end |save front doc as PDF|

|save front doc as PDF| to "Save PDF Test.pdf" from "TextEdit" (* or from "Safari", etc. *)

Thanks Kai, my big problem is that I have to avoid using extrasuites, because I try to make our IT-department to change a Quickkey-script in favour of my applescript, and my best argument for the change is that applesript is already in the system, so I would like to make a clean appllescript… so if anyone know how to make this I would be happy ( I do understand I probably wont be happy… :wink:

Regards / Johan