The idea is this script will choose a printer depending on which chain the file belongs to, then print using Acrobat. It all seems to work lovely, but the script gets stuck on the print dialog box until I manually click ‘OK’.
I have tried a few things but none work at the moment.
-
delay 3
tell application “Adobe Acrobat Pro” to keystroke return
-
delay 3
tell application “Adobe Acrobat Pro” to keystroke (ASCII character 3)
-
and this one, a simple keystroke return.
Acrobat ignore everything I have tried. Any ideas?
on adding folder items to this_folder after receiving these_items
tell application "Finder"
set aFileToPrint to these_items
set wtPrint to aFileToPrint
end tell
--print time
set {tid, text item delimiters} to {text item delimiters, "_"}
tell application "Finder"
repeat with aFileToPrint in these_items
set fileName to name of aFileToPrint
set {jc1, jc2, wc} to text items of fileName
set chain to text 3 thru -1 of wc
try
if chain = "C" then
tell application "Printer Setup Utility" to set current printer to printer "HP 8550"
tell application "Adobe Acrobat Pro"
print aFileToPrint
keystroke return
end tell
else if chain = "PCW" then
tell application "Printer Setup Utility" to set current printer to printer "Rhubarb & Custard"
tell application "Adobe Acrobat Pro"
print aFileToPrint
keystroke return
end tell
end if
end try
end repeat
end tell
set text item delimiters to tid
end adding folder items to
Hi,
first of all, the keystroke command belongs to System Events, not to Acrobat or the Finder.
Acrobat Pro has an own print command named print pages.
I don’t understand this part at all
tell application "Finder"
set aFileToPrint to these_items
set wtPrint to aFileToPrint
end tell
the Finder is not needed to define any variable
and you define only two new pointers to the same reference.
For example when you delete an item in these_items,
this item “disappears” also in aFileToPrint and wtPrint.
Later you use aFileToPrint as index variable in the repeat loop
Yep that was a pointless way to start the script, thats me chopping scripts together. Now to bypass the OK button and I’ll be laughing!
on adding folder items to this_folder after receiving these_items
set {tid, text item delimiters} to {text item delimiters, "_"}
tell application "Finder"
repeat with aFileToPrint in these_items
set fileName to name of aFileToPrint
set {jc1, jc2, wc} to text items of fileName
set chain to text 3 thru -1 of wc
try
if chain = "C" then
tell application "Printer Setup Utility" to set current printer to printer "HP 8550"
tell application "Adobe Acrobat Pro"
print aFileToPrint
end tell
else if chain = "PCW" then
tell application "Printer Setup Utility" to set current printer to printer "Rhubarb & Custard"
tell application "Adobe Acrobat Pro"
print aFileToPrint
end tell
end if
end try
end repeat
end tell
set text item delimiters to tid
end adding folder items to
try this
on adding folder items to this_folder after receiving these_items
set {tid, text item delimiters} to {text item delimiters, "_"}
repeat with aFileToPrint in these_items
tell application "Finder" to set fileName to name of aFileToPrint
set {jc1, jc2, wc} to text items of fileName
set chain to text 3 thru -1 of wc
try
if chain = "C" then
tell application "Printer Setup Utility" to set current printer to printer "HP 8550"
else if chain = "PCW" then
tell application "Printer Setup Utility" to set current printer to printer "Rhubarb & Custard"
end if
if chain is "C" or chain is "PCW" then
tell application "Adobe Acrobat Pro"
open aFileToPrint
print pages active doc PS Level 3 without binary output and shrink to fit
close active doc
end tell
end if
end try
end repeat
set text item delimiters to tid
end adding folder items to
Thank you!
I changed this line though as it wasn’t fitting to the page for some reason.
print pages active doc PS Level 2 with binary output and shrink to fit