I’m still pretty new to applescript, but I always find what I’m looking for here, same goes for the script I’m doing now, problem is it doesn’t work when put together, can someone tell me why, and if there is a better solution? I would be very happy if so… here we go:
I have two parts, working when not put together, first part:
tell application "Finder"
activate
select file "Name of file" of folder "TEST" of desktop
open selection
select menu item "Collect for output..." of menu "File" of application "QuarkXPress Passport"
end tell
(Not completely shure about the english menu names…)
This leaves me vith a dialog that I want to say OK to, and that I can do seperatly with this script (also found here ;-):
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
keystroke return
end tell
end tell
Though, put together, like this the keystroke return wont work… it times out…
tell application "Finder"
activate
select file "Name of file" of folder "TEST" of desktop
open selection
select menu item "Collect for output..." of menu "File" of application "QuarkXPress Passport"
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
keystroke return
end tell
end tell
end tell
tell application "Finder"
activate
select file "Name of file" of folder "TEST" of desktop
open selection
select menu item "Collect for output..." of menu "File" of application "QuarkXPress Passport"
end tell
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
keystroke return
end tell
end tell
ThanksJacques, but this dosn’t work fo me, it doesn’t like the " click menu item “Collect for output…” of menu “File” of menu bar item “File” of menu bar 1" command, I get a “NSReceiverEvaluationScriptError: 4” (I am in Tiger, with NO Extra Suites or anything like that, might be the problem???)
But I did get it to work, even tough I don’t really know why, just tested some delays , timeouts and “try:s” (trial and error
But knowing my solution probably isn’t the most beutiful one, I will be glad for nicer suggestions still! And if someone knows why this works, while my old one didn’t, please tell me
(Now I also have “the rest” of the process of the script…)
Regards / Johan
tell application "Finder"
activate
select file "Name of file" of folder "TEST" of desktop
open selection
with timeout of 1 second
try
select menu item "Collect for output..." of menu "File" of application "QuarkXPress Passport"
end try
end timeout
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
keystroke return
set frontmost to true
keystroke return
with timeout of 1 second
try
delay 7
set frontmost to true
keystroke return
end try
end timeout
end tell
end tell
end tell
Not to be too simplistic, but in the first part you have a tell addressing the application “QuarkXPress Passport”, and in the second part it’s addressing the process “QuarkXPress”.
Could this be it? I tried your script, changing the application and the process to the same name, and it worked fine.
tell application "Finder"
activate
select file "Name of File" of folder "TEST" of desktop
open selection
with timeout of 1 second
try
select menu item "Collect for output..." of menu "File" of application "QuarkXPress"
end try
end timeout
tell application "System Events"
tell process "QuarkXPress"
set frontmost to true
keystroke return
set frontmost to true
keystroke return
with timeout of 1 second
try
delay 7
set frontmost to true
keystroke return
end try
end timeout
end tell
end tell
end tell
Hello mr pockets… you might have a point there, never really understood when to use wich, if someone knows this I am very interested, I tend to use the version that works…
The problem (I think) wasn’t with your “tell” commands, but with the naming of the application you’re using to do the collect.
Your script is actually sending commands to two different applications; first it’s telling the Finder to select the Collect For Output menu of QuarkXPress Passport, then it’s telling System Events to hit the “Save” button within the Collect For Output menu of QuarkXPress (not QuarkXPress Passport).
Assuming you’re using only QuarkXPress Passport, replace “QuarkXPress” with “QuarkXPress Passport” in the second part of the script…see if it works then.