print without dialog

I am very new to applescripting and I need some help. I am trying to create an applescript for InDesign CS2 that prints the current open file. I have read some of the Adobe scripting guide and it has a very basic script to do this but I keep getting the dialog box. I would like the script to run without a dialog box.

tell application "Adobe InDesign CS2"
	print active document
end tell

eventually I would like to set print parameters but if I could just get it to print without a dialog box I think I could take it from there.

Thanks in advance for your help.

Julian

you were very close - just needed 2 addition words…

tell application "Adobe InDesign CS2"
	print active document without dialog
end tell

Is there an equivalent for Photoshop?

tell application "Adobe Photoshop CS2"
    print document docfile without dialog
end tell

This compiles even though it’s not in the dictionary, but only “without”, not “without dialog” is recognized as a keyword/phrase, and it prints but still puts up a dialog first. I can’t get System Events/keystroke to handle this properly either, although I assume there must be a way. Maybe a call method from the App Kit framework?

Thanks a lot…

  • Dan

hmmm - that code from Adobe is even posted in the Photoshop Scripting reference - but it doesn’t work for me either. It’s strange that they use that example - but then the ‘dialog’ isn’t even an option for the print command in the library.

I unfortunately never ran into this before - so I don’t know what the best solution is.

Hi Dan,

This works for me

tell application "Adobe Photoshop CS2" to activate
tell application "System Events"
	key code 35 using {command down}
	-- delay 1 -- or more for very large docs <-- 
	key code 36
end tell

Of course you get the dialog window, but you don’t need to press any keys.

I guess that save the doc as a temp file and then use ‘lpr’ could do it without dialog, but as I don’t come from the Unix world, I’d appreciate if one of the *nix guys I see on this forum would be kind and give an example/try on a solution for it.

Yannis A.

[edit] You probably don’t need the delay at all

Hello

Always the same problem, key codes for US keyboards don’t work for french ones.

May you give the name of the character you type in a comment ?

I assumes that key code 35 types a “p” but what is key code 36 doing ?

I was thinking of

keystroke “p” using {command own}
keystroke return

I can’t test as I don’t own these apps.

At least, this one works for me:

tell application "TextEdit" to activate
tell application "System Events"
	keystroke "p" using {command down}
	-- delay 1 -- or more for very large docs <-- 
	keystroke return
end tell

Yvan KOENIG

Hi Yvan,

Yes, it’s exactly what you’ve ‘keystroked’.

‘key code’ is a ‘bad habit’ :), but it have always worked better than ‘keystroke’ on my Greek keyboards. Don’t ask me why, 'cos I’ve never figured that out.

Aside from that, neither of these commands works with Adobe apps when “Input Source = Greek”.

Yannis

Hello

Is there somewhere a document giving the code values for different keyboards ?

Yvan KOENIG

Yannis -

Thanks very much, that works perfectly - I don’t understand why I couldn’t get System Events/keystroke to work earlier but obviously it was something different than what you’ve provided. As a matter of fact, if I substitute keystroke “p” with {command down} for key code 35 and substitute keystroke return for key code 36 it no longer works, but key code 35, key code 36 works just fine. Don’t know why…

Thanks again!

  • Dan