G’day scripters.
Quark is a pain. I want to set the two top buttons in the print dialog box to a preset ‘Quark Printer’.
I’ve managed to get the pop up button 2 to set correctly, but the second Print Preset button ‘UI element 16’ refuses to respond to anything I’ve tried.
Any ideas please?
Regards
Santa
tell application "QuarkXPress"
activate
repeat
if exists window 1 then exit repeat
delay 0.2
set x to x + 1
if x = 25 then exit repeat
end repeat
set TempAttachmentName to "20090412 121212Z 3"
--my QuarkSetProperties()
tell document 1
set TheHeight to page height as real
set TheMargin to bottom margin as real
set ThePoints to points per inch as real
set page height to TheHeight + 0.7
set bottom margin to TheMargin + 0.7
set captionBox to make new text box at end with properties {bounds:{(TheHeight * ThePoints + 2), 6, (TheHeight * ThePoints) + 60, 400} as points rectangle, color:null, name:"Caption Box"}
set story 1 of captionBox to TempAttachmentName
set font of every paragraph of captionBox to "IDAutomationHC39M"
end tell
set temp to get name of every window as list
repeat with x in reverse of temp
if "Layout" is in x then
set y to last word of x
exit repeat
end if
end repeat
delay 0.5
set temp to ("Print Layout " & y) as text
activate
tell application "System Events" to tell process "QuarkXPress"
keystroke "p" using command down
delay 1
try
if exists button "OK" of window 1 then click button "OK" of window 1
end try
delay 3
end tell
tell application "System Events" to tell process "QuarkXPress"
tell pop up button 2 of window temp
click
delay 1
end tell
set x to 0
repeat
try
set x to x + 1
set temp2 to name of menu item x of menu 1 of pop up button 2 of window temp
--display dialog temp as text
if temp2 = "Quark Printer" then
click menu item x of menu 1 of pop up button 2 of window temp
exit repeat
end if
on error
click menu item (x - 1) of menu 1 of pop up button 2 of window temp
exit repeat
end try
end repeat
-- This doesn't work, in all permutations
try
tell UI element 16 of window temp
set {xPosition, yPosition} to position
set {xSize, ySize} to size
end tell
-- modify offsets if hot spot is not centered:
delay 2
select UI element 16 of window temp
tell UI element 16 of window temp
click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
end tell
set x to 0
tell UI element 16 of window temp
repeat
try
set x to x + 1
set temp2 to name of menu item x of menu 1
if temp2 = "Quark Printer" then
click menu item x of menu 1
exit repeat
end if
if x ≥ 20 then exit repeat
end try
end repeat
end tell
on error theerror
display dialog theerror
end try
end tell
end tell