Using Preview to print Images

Hi All,

This is very much like other printing issues, but I was hoping to make a script that could universal for all types of OS X.

heres what I have:

tell Application “Preview”
activate
set printFile to alias “Macintosh HD:Applications:appPath:after.jpg”
open printFile
print printFile
end tell

Why won’t that work? I’ve noticed a lot of responses that have very Jaguar or Panther specific code using system events and keystrokes…I can’t really have this unless there’s a way with applescript to tell what OS I’m working with…

this works but only on Panther:

tell application “Preview”
activate
open “Macintosh HD:Applications:appPath:after.jpg”
end tell
tell application “System Events”
tell process “Preview”
tell front window
keystroke “p” using command down
tell window “Print”
end tell
end tell
end tell
end tell

Please Help

thanks in advance!

Hello c-money,

OS/X will probably always be changing-which isn’t to say “changing for the better”. Unfortunately, in my short and limited experience with Macs and Applescript this means that certain scripts will have to be adapted to encompass changes in OS: (a mon avis-in my opinion).

Try the following script, you may find it useful:

tell application “OmniGraffle”
print (choose file)
quit
end tell

I can’t take credit for this script. I believe I found it on Code Exchange or somehwere else on the MacScripter.net site.

Sincerely,

Variable as the shade

Thanks for the reply Variable as the Shade,

But this script doesn’t seem to work, are you sure it’ll will work with jpg files?

thanks
c-money