I’m having a problem scripting the GUI in InDesign. I am using InDesign CS 3 with 10.5. Below is what PART of my script looks like;
tell application "System Events" to tell process "Adobe InDesign CS3"
click menu item "Print..." of menu of menu bar item "File" of menu bar 1
click pop up button 5 of window "Print" --Print Preset
--Select second printer preset
keystroke (ASCII character 31) -- down arrow key
keystroke (ASCII character 31) -- down arrow key
keystroke return
--Move to second print dialog box
click button "Printer."
delay 1
--Move to "SAVE" dialog box
click button "Print"
--Give the file a name
keystroke theName
delay 2
--Print to PDF
keystroke return
end tell
When the script gets to the "click button “Printer…”, the script actually clicks the “Printer…” button (I can see it change color) however nothing happens. The new “Print” dialog box doesn’t open as it should. Is there something I’m missing with this script? I appreciate anyone’s help with this. Thank you in advance!!
I want to paste the name in the “Save” dialog box, that follows the “Print” dialog box you get when you hit the “Printer…” button. InDesign always adds an @ sign with the current percentage, and does not remove the .indd extension. The name of my files have to be 9 characters, with a .pdf extension. Also, (FYI) EXPORT to pdf files do not work through our workflow.
It’s because of the PDF producer. When you PRINT to pdf Acrobat Distiller creates the PDF, when you EXPORT, PDF LIbrary makes the PDF. The PDF library causes unpredictable results in our workflow, so we don’t use it for press pdfs.
Here’s a script I have to print seps to a .ps file and then have Distiller rip it to a PDF using one of the settings. I agree with the tone of the previous posts that you are much better off scripting InDesign’s print and then Distiller directly then trying to GUI script. It often is unpredictable, as you are seeing when you tell it to click a button and it seems to click the button but not give you any result.
Anyway, here is what I have. That should give you a good start:
tell application "Acrobat Distiller" to launch
tell application "Adobe InDesign CS3"
activate
tell active document
set myName to (name of it) as text
set AppleScript's text item delimiters to {"."}
set fileBase to first text item of (myName as string)
set AppleScript's text item delimiters to {""}
set PS_file_path to (PathToDesktop & fileBase & ".ps") as text
tell print preferences
set use document bleed to print to false
set bleed chain to true
set bleed top to "0.125\""
set include slug to print to true
set bleed marks to false
set color bars to false
set crop marks to true
set page information marks to true
set registration marks to true
set printer to postscript file
set PPD to "AdobePDF 8.0"
set print file to PS_file_path
set color output to separations
end tell --end tell print prefs
end tell --end tell active doc
display dialog ("Printing Separations PS file.") buttons "SEPS" giving up after 1
try
with timeout of 1800 seconds
print active document without print dialog
end timeout
on error
delay 1
with timeout of 1800 seconds
print active document without print dialog
end timeout
end try
tell active document to close saving no
end tell --end tell InDesign
--Set up variable for Distiller
set POSIXPath2PSFile to POSIX path of (PS_file_path as alias)
set PathToHQPrintSetup to ((path to application support as string) & "Adobe:Adobe PDF:Settings:High Quality Print.joboptions")
set PathToHQPrint to POSIX path of PathToHQPrintSetup
with timeout of 3600 seconds
tell application "Acrobat Distiller"
activate
Distill sourcePath POSIXPath2PSFile adobePDFSettingsPath PathToHQPrint
end tell
end timeout
tell application "Finder"
activate
repeat while not (exists file (PathToDesktop & fileBase & ".pdf"))
delay 0.5
end repeat
try
delete file PS_file_path
end try
end tell
But if you still want to GUI script, you might need a delay between the return that selects your preset and the clicking of the print button. Basically, always put a delay between every step. Also, if “Click button ‘Print…’” is not working, you might be able to clcik that button with a simple keystroke return. Sometimes that is more reliable.