Requesting help with GC Applescript printing, please.

This area contains the messages from the old Yahoo gcmac group after the port.
brian_christmas
Posts: 0
Joined: Sun Jun 07, 2015 7:20 am

Requesting help with GC Applescript printing, please.

Post by brian_christmas »

G'day GC usersI'm trying to print GC documents with Applescript, and am having awful trouble.I've tried the Print Dialog GUI approach, which GC ignores, and the...print document 1 with properties {copies:1, target printer:theLargePagePrinter} without print dialogNothing works.I need to print to a particular printer, out of two, single copy,with printer presets.Under OS 9 GC had good printer support, but it  seems to have been dropped in favour of ever increasing details in OS X.Can anyone guide me on this please.Using Yosemite 10.3property theLargePagePrinter : "Quark Printer"tell application "GraphicConverter 9" activate set GCWindowName to name of window 1 as text tell current application to delay 0.2 set tempflag to false # if exists document 1 then # print document 1 with properties {target printer:my theLargePagePrinter} print dialog no tell application "System Events" to tell process "GraphicConverter 9" tell current application to delay 0.4 keystroke "p" using command down tell current application to delay 0.2 set x to 0 repeat until exists sheet 1 # of window 1 tell current application to delay 0.1 set x to x + 1 if x > 50 then say "exiting" exit repeat end if end repeat tell current application to delay 0.2 set reShowSheet to false tell current application to delay 0.1 tell sheet 1 if exists button "Show Details" then click button "Show Details" repeat until exists button "Hide Details" tell current application to delay 0.1 end repeat tell current application to delay 0.2 click button "Cancel" set reShowSheet to true end if end tell if reShowSheet then keystroke "p" using command down repeat until exists sheet 1 #of window 1 tell current application to delay 0.1 end repeat end if tell current application to delay 0.4 click pop up button 4 of sheet 1 of window GCWindowName set x to 0 repeat until exists menu 1 of pop up button 4 of sheet 1 of window GCWindowName tell current application to delay 0.1 set x to x + 1 if x ≥ 30 then exit repeat end repeat tell current application to delay 0.2 try click menu item (my theLargePagePrinter) of menu 1 of pop up button 4 of sheet 1 of window GCWindowName on error click menu item 1 of menu 1 of pop up button 4 of sheet 1 of window GCWindowName end try tell current application to delay 0.2 click pop up button 3 set x to 0 repeat until exists menu 1 of pop up button 3 of sheet 1 of window GCWindowName tell current application to delay 0.1 set x to x + 1 if x ≥ 30 then exit repeat end repeat tell current application to delay 0.2 try click menu item (my theLargePagePrinter) of menu 1 of pop up button 3 of sheet 1 of window GCWindowName on error click menu item 1 of menu 1 of pop up button 3 of sheet 1 of window GCWindowName end try tell current application to delay 0.2 try keystroke return end try tell current application to delay 0.2 try click button "Print" of sheet 1 of window GCWindowName end try # set my didItPrint to true set tempflag to true end tellend tell
brian_christmas
Posts: 0
Joined: Sun Jun 07, 2015 7:20 am

Re: Requesting help with GC Applescript printing, please.

Post by brian_christmas »

G'day again.I just checked, and there was a GC update, which works with the 'Print document 1 with properties'.However, is there a property for selecting the printer presets, something like...print document 1 with properties {target printer:theLargePagePrinter, printer presets:theLargePagePrinter} print dialog noRegardsSanta
thorstenlemke
Posts: 0
Joined: Fri Dec 30, 2016 12:00 pm

Re: Requesting help with GC Applescript printing, please.

Post by thorstenlemke »

Hello Brian,sorry not yet due the change to the cocoa print manager.Thorsten However, is there a property for selecting the printer presets, something like...print document 1 with properties {target printer:theLargePagePrinter, printer presets:theLargePagePrinter} print dialog no
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Re: Requesting help with GC Applescript printing, please.

Post by Brian Christmas »

G’day ThorstenSince I’ve re-booted this morning, the code that worked yesterday no longer works.It defaults to the default printer. Unfortunately, because I’m checking for the Printer states, the default printer somehow is set to the last printer in the System Preferences list, which happens to be a different printer. I don’t want my Clients to change their printer names.The following cycles with printerNames of ‘rtfd Printer’, ‘Quark Printer’.set defaultPrinterState to do shell script ("lpstat -p " & printerName)set defaultPrinterProperties to do shell script ("lpoptions -d " & printerName) I’m desperate to find an answer to this problem, is their ANY solution to allow GraphicConverter to choose a not-default-printer, (in my case), ‘Quark Printer’ (the name of theLargePagePrinter)? tell application "GraphicConverter 9" activate print document 1 with properties {target printer:theLargePagePrinter} print dialog no if addBarCode then set my theJobsTally to (my theJobsTally) + 1 # Add to printed jobs Tally end tellRegardsSanta
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Re: Requesting help with GC Applescript printing, please.

Post by Brian Christmas »

G’day again Thorsten. My apologies, the fault lay at my end (I think). My apps opening GC 9.6.1, but when GC went to print, it was pulling an old version 9.4 off of my week old Carbon Copy Cloner external backup. I’ve deleted the GC copy from the backup, and it’s printing fine. My daily backup has 9.6.1. It might be a good idea to make sure GC printing uses the latest version of GC that’s available, if possible. Regards Santa
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Requesting help with GC Applescript printing, please.

Post by Brian Christmas »

  G'day ThorstenIn further experimenting with  Graphicconverter printing, I’ve struck further ongoing problems.I re-named my printers (because my Clients have different printer names), and the direct printing once again uses a different printer to the stipulated one.property theLargePagePrinter : "Large Page Printer"tell application "GraphicConverter 9" activate print document 1 with properties {target printer:(my theLargePagePrinter)} print dialog noend tellThe above prints to the first printer in the System Preferences printer list, even though I’ve got a printer, and print preset, set in Gc 9.6.1, i.e. the ‘Large Page Printer’.I’m resorting to GUI scripting, which cannot use the window name for ‘Untitled’ windows, as the name resolves to ‘missing value’. GUI scripting is proving to be slow and erratic, however.Thorsten, is there any way printing from GraphicConverter using Applescript can be improved. The present situation is not good.RegardsSantaproperty theLargePagePrinter : "Large Page Printer"tell application "GraphicConverter 9" activate set GCWindowName to name of window 1 as text tell current application to delay 0.2 set tempflag to false # if exists document 1 then # print document 1 with properties {target printer:my theLargePagePrinter} print dialog no tell application "System Events" to tell process "GraphicConverter 9" tell current application to delay 0.4 keystroke "p" using command down tell current application to delay 0.2 set x to 0 repeat until exists sheet 1 of window 1 # GCWindowName tell current application to delay 0.1 set x to x + 1 if x > 50 then say "exiting" exit repeat end if end repeat tell current application to delay 0.2 set reShowSheet to false tell current application to delay 0.1 tell sheet 1 of window 1 # GCWindowName if exists button "Show Details" then click button "Show Details" repeat until exists button "Hide Details" tell current application to delay 0.1 end repeat tell current application to delay 0.2 click button "Cancel" set reShowSheet to true end if end tell if reShowSheet then keystroke "p" using command down repeat until exists sheet 1 of window 1 # GCWindowName tell current application to delay 0.1 end repeat end if tell current application to delay 0.4 click pop up button 4 of sheet 1 of window 1 # GCWindowName set x to 0 repeat until exists menu 1 of pop up button 4 of sheet 1 of window 1 # GCWindowName tell current application to delay 0.1 set x to x + 1 if x ≥ 30 then exit repeat end repeat tell current application to delay 0.2 try click menu item (my theLargePagePrinter) of menu 1 of pop up button 4 of sheet 1 of window 1 # GCWindowName on error click menu item 1 of menu 1 of pop up button 4 of sheet 1 of window 1 #GCWindowName end try tell current application to delay 0.2 click pop up button 3 of sheet 1 of window 1 set x to 0 repeat until exists menu 1 of pop up button 3 of sheet 1 of window 1 # GCWindowName tell current application to delay 0.1 set x to x + 1 if x ≥ 30 then exit repeat end repeat tell current application to delay 0.2 try click menu item (my theLargePagePrinter) of menu 1 of pop up button 3 of sheet 1 of window 1 # GCWindowName on error click menu item 1 of menu 1 of pop up button 3 of sheet 1 of window 1 # GCWindowName end try tell current application to delay 0.2 try keystroke return end try tell current application to delay 0.2 try click button "Print" of sheet 1 of window 1 # GCWindowName end try   set tempflag to true end tellend tell
thorstenlemke
Posts: 0
Joined: Fri Dec 30, 2016 12:00 pm

Re: Requesting help with GC Applescript printing, please.

Post by thorstenlemke »

Dear Santa,sorry, no. Because the complete print mechanism is done by Cocoa.Thorsten Thorsten, is there any way printing from GraphicConverter using Applescript can be improved. The present situation is not good.
Brian Christmas
Posts: 0
Joined: Thu Nov 18, 2010 10:02 pm

Re: Requesting help with GC Applescript printing, please.

Post by Brian Christmas »

Thanks Thorsten.I’ve lodged a bug report, but I’ve continued to try different code trials. Just trying every avenue.I’ve discovered that using the lp code lpoptions -d switched the referred printer as the default printer, but when using the code below, the printer dialog sheet remains unresponsive to applescript. It freezes on display, unless physically clicked on.I’m posting on the off chance someone might know a way of getting the sheet to react to anything but a physical click. Cocoa is a pain!Any takers?RegardsSantaproperty theLargePagePrinter : "Large Page Printer"property theSmallPagePrinter : "A4 Printer"# Presume the default printer is set to 'A4 Printer'set printerName to ""set p to 2set tempPrinterName to my theLargePagePrinter as textset p to 3repeat with x from 1 to (count of tempPrinterName) if character x of my tempPrinterName is not " " then set printerName to printerName & (character x of tempPrinterName) as text else set printerName to printerName & "_" as text end ifend repeatset defaultPrinterProperties to do shell script ("lpoptions -d " & printerName)try tell application "GraphicConverter 9" activate # Using 'print dialog no' doesn't work, still uses first listed printer # Using 'print dialog yes', chooses correct printer, but printer sheet freezes unless 'Print' is physically clicked, and clicking 'Cancel' gives a 'GraphicConverter 9 got an error:AppleEvent handler failed' error print document 1 print dialog yes print document 1 with properties {target printer:(theLargePagePrinter)} print dialog yes   say 1 activate tell application "System Events" to tell process "GraphicConverter 9" keystroke return end tell end tellon error errmsg display dialog errmsgend try
Harry Whitfield
Posts: 0
Joined: Tue Dec 28, 2010 1:01 pm

Re: Requesting help with GC Applescript printing, please.

Post by Harry Whitfield »

Brian,This appears to do what I think you want:property nameOfPrinter : "Print to VipRiser" -- the printer to be used-- save name of current printertell application "Printer Setup Utility" set oldPrinter to name of current printer -- set new printer set current printer to printer nameOfPrinterend telltell application "GraphicConverter 9" activate tell application "System Events" to tell process "GraphicConverter 9" delay 0.5 keystroke "p" using command down delay 0.5 click button 1 of sheet 1 of window 1 end tellend tell-- reset the old printertell application "Printer Setup Utility" set current printer to printer oldPrinterend tellHarry.
harry152566
Posts: 0
Joined: Fri Jun 12, 2015 5:41 pm

Re: Requesting help with GC Applescript printing, please.

Post by harry152566 »

Brian,If the Printer Setup Utility is not available on your system, the following code will select a printer and print the current GC window to it.-- set new printer do shell script ("lpoptions -d Print_to_VipRiser") delay 1 tell application "GraphicConverter 9" activate tell application "System Events" delay 0.5 keystroke "p" using command down delay 0.5 click button 1 of sheet 1 of window 1 of process "GraphicConverter 9" end tell end tellHarry.
Post Reply