Friday, July 30, 2010

#1 2005-07-12 12:38:44 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

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.

Applescript:

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.

Applescript:

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)


One mans trash is another mans treasure

Filed under: System

Offline

 

#2 2005-07-13 03:11:31 pm

harges
Member
From: San Francisco, CA
Registered: 2003-03-15
Posts: 85
Website

Re: Quark UI Scripting

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/vie … php?t=8016

--Open this script in a new Script Editor window.

tell application "QuarkXPress Passport"
     activate
     tell print setup of document 1
          set orientation to landscape
          set page position to center position
          set print colors to black and white
          set print spreads to true
          set printer type to "GCC Elite XL 20/600"
          set reduce or enlarge to "100%"
          set registration marks to centered
     end tell
     
     try
          tell application "System Events"
               tell process "QuarkXPress"
                    tell menu bar 1
                         tell menu bar item "File"
                              tell menu "File"
                                   tell menu item "Export"
                                        tell menu "Export"
                                             click menu item "Layout as PDF..."
                                        end tell
                                   end tell
                              end tell
                         end tell
                    end tell
                    delay 1
                    tell window "Export as PDF"
                         click button "Save"
                    end tell
               end tell
          end tell
     on error
          display dialog "UI not working"
     end try
end tell

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

Offline

 

#3 2005-07-14 07:34:25 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Quark UI Scripting

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


One mans trash is another mans treasure

Offline

 

#4 2006-02-15 09:10:02 am

KRAFTWERK
Member
From: SWEDEN
Registered: 2004-10-19
Posts: 22

Re: Quark UI Scripting

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? ;-) (seriously ment as a question though)

Regards / Johan

Offline

 

#5 2006-02-15 08:20:02 pm

kai
Member
From: Brighton, UK
Registered: 2005-05-28
Posts: 912

Re: Quark UI Scripting

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:

Applescript:

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. *)


kai

Filed under: System, extra

Offline

 

#6 2006-02-16 09:18:54 am

KRAFTWERK
Member
From: SWEDEN
Registered: 2004-10-19
Posts: 22

Re: Quark UI Scripting

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... ;-)

Regards / Johan

Last edited by KRAFTWERK (2006-02-16 09:21:47 am)

Offline

 

Board footer

Powered by FluxBB

[ Generated in 1.038 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)