vasanthi,
Your script indeed works, but it does not do what the original poster wants. This command is in the original post (which was all run together and hard to read):
if button returned of UserResponse is "Yes" then tell application "QuarkXPress" select menu item "Collect for Output..." of menu "File"
If Quark is running with a recently saved document open, the following script gets as far as the Collect for Output dialog.
display dialog "Do you need a Collect for Output?" buttons {"Yes", "No"} default button "Yes"
set UserResponse to the button returned of the result
if UserResponse is "Yes" then
tell application "QuarkXPress"
select menu item "Collect for Output..." of menu "File"
end tell
end if
tell application "System Events"
tell process "QuarkXPress"
keystroke (ASCII character 13)
end tell
end tell
--if UserResponse is "No" then
-- display dialog "You just Cancel the script"
--end if
The problem I've always had is, how to click the "Save" button in the Collect for Output dialog box. Here, I've tried to use System Events to press the Return key on the keyboard, but it doesn't work for me. I've also used UI Element Inspector to try and find a way to address the Save button, but without luck.