UI Scripting InDesign

Hi Folks-

I figured out some of the necessary syntax to get UI scripting to work. Now I have a bit of code that I hoped would result in printing, and it will compile -but it’s not working. Can anyone tell me what I’m doing wrong?

on adding folder items to this_folder after receiving added_items
	activate application "Adobe InDesign CS2"
	tell application "Adobe InDesign CS2"
		open added_items
		tell application "System Events"
			tell process "InDesign"
				tell menu bar 1
					tell menu bar item "print"
						tell pop up button 4
							select menu item " postscript" of menu -2.147483648E+9 of UI element 2
							click button "Save" of window "Print"
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end adding folder items to

thanks so much


Can you tell me exactly what you are trying to do? I have CS2 and can’t figure out your references, aren’t matching mine.

If you are trying to manipulate the Printer popup at the top of the print dialog, I wish you the best of luck. I’ve got a project on hold that I never did get to work reliably because the references kept changing, oddly enough, and the values in the popup don’t seem to be accessible to AppleScript, despite Prefab’s UI Browser being able to see them.

Describe what exactly you are trying to do and I’ll give you Prefab’s UI Browser output on my end, see if it helps you any.

Hi Kevin-

I’m trying to generate postscript files based on various presets from InDesign using the Print function, rather than the Export function.

Our EPS and PDF generation process has up until recently been to generate EPS files through the print menu (print>printer…>PDF>save PDF as postscript). Then we would typically send off the EPS to our printing department, and generate a PDF from the EPS via Acrobat Distiller as confirmation.

This has typically generated the most reliable postscript files with the fewest errors. Using the export function has sometimes given us errors, and Adobe has confirmed that our legacy fonts trips some errors (should upgrade to OpenType).

I have successfully scripted the export function (via help from this group) but those were only for intermediate proofs. for generating final files, I’d still rather use the print function than export.

hope this makes sense


Hi Ralph,

do you know the AppleScript documentation of Adobe

It’s new for CS 3 but I think the basics work also in CS 2

hope it helps

Very interesting. I had overlooked it because it said CS3 but it does have some interesting info- I’m reading it now.



Be careful with the EPS format and using Transparency over spot colors…EPS doesn’t support that very well and can maul the looks of the file. Going from a PostScript (.ps) file to Distiller is more reliable for creating PDFs. Beat my head against that wall for months with Adobe, try to save others the pain.

I could never get UI scripting to access the Printer popup in the print dialog box. My best guess so far has been that there is some wierd interaction between Adobe’s dialog and the Mac OS itself, so I had to shelve my project, which was similar to yours, for now.

My project was to save a PS file and hand it off the Distiller. I was working with Illustrator first, but InDesign would have followed. I got hung-up on the printer selection as well as proper cropping of the PS file (so it didn’t include unnecessary white space). I tried Adobe’s AppleScript commands to export the PS without UI scripting, but it kept ignoring settings related to page size and forcing to Letter no matter what I did. So I was resorting to UI scripting because of that.

It’s a mess, trust me. A couple of very wonderful folks here also beat their heads against it with me, don’t think we ever made it work. I kinda hope Adobe irons-out the bugs in CS3, honestly. We won’t be going to CS3 any time soon, but maybe by the time I get back to my PS-to-PDF project, we will have upgraded. crosses fingers

I try my best to avoid gui script when posssible here is what i do to make a ps file from indesign

I first make a printer style with the printer set to Postscript file and the PPD set to whatever I need it to be.
then i open the doc and run this

set dt to ("" & (path to desktop))
set PSFile to (dt & "test.ps")
tell application "InDesign 2.0.2"
	set print orientation of printer style "myPrintStyle" to portrait
	set print file of printer style "myPrintStyle" to ("" & PSFile)
	print document 1 using "myPrintStyle" without print dialog
end tell

I hope this helps


thanks for the replies…

though inelegant, the solution I’ve come up with is to first generate a PDF from InDesign and then generate a PS file (multipage- EPS won’t cut it) from Acrobat. I may try mcgrailm’s solution as well.

set vmyDesktop to alias ((path to desktop as string))
set vfullpath to (vmyDesktop as string) & "myeps.ps"
tell application "Adobe Acrobat 7.0 Professional"
	save front document using PostScript Conversion to file vfullpath



I Find it in best practice to limit the conversion of a file as drawing a graphic importing it into indesign saving it as a pdf then converting it to a ps file that will later then be converted to an eps that will then be imported into some other program that will then be sent to the rip is not only cumbersome to trouble shoot but also has a higher risk for problems,

best regards,

good point.

I just tried MM’s method, and with a little tweaking for CS2 it worked. I had to comment out the portrait bit (I’ll work on this later), but all it took otherwise was changing “styles” to “presets”. Hopkin’s “Applescripting InDesign CS” notes this was a change going to CS.

set dt to ("" & (path to desktop))
set PSFile to (dt & "test.ps")
tell application "Adobe InDesign CS2"
	--set print orientation of printer preset "postscript" to portrait
	set print file of printer preset "postscript" to ("" & PSFile)
	print document 1 using "postscript" without print dialog
end tell