Starting and running Quark

Hello -

I have 2 script applications:

caller:

set qpQuark to quoted form of POSIX path of "Macintosh HD:Projects:DOLE_DOCS:called.app"
set qpDoc to quoted form of "Macintosh HD:Projects:Path:To:QuarkDocument.qxp"
do shell script "osascript " & qpQuark & " " & qpDoc

and called:

on run argList
	set docPath to item 1 of argList
	-- launch application "Macintosh HD:Applications:QuarkXPress 7.1:QuarkXPress.app"
	tell application "Macintosh HD:Applications:QuarkXPress 7.1:QuarkXPress.app"
		activate
		open file docPath remap fonts no use doc prefs no
	end tell
end run

caller calls called to open a Quark document. The problem is that even though Quark is told to activate in called, nothing happens until I manually click on the Dock’s Quark icon, then it comes to the front and the document loads. If I don’t, Quark starts but then it just sits there and times out without loading the document.

If I uncomment the launch command in called there’s no difference - same problem. If I replace “launch” with “run”, I get the message “QuarkXPress got an error: Can’t continue run. (-1708)”.

If Quark is already running, I have no problem in any case.

It’s important that this runs unattended, and that it be able to start up Quark if it’s not running. Can anyone provide some advice?

Thanks very much…

  • Dan

Dan,

Now this is a good time… pardon my sarcasm folks but I am become more and more jaded by the lack of applescript support coming from all of the vendors from Apple to Quark to Adobe there always seems to be some nut ball thing we have to do to do the simplest things.


ignoring application responses
	tell application "QuarkXPress" to activate
end ignoring
tell application "System Events" to delay 5
tell application "QuarkXPress" to activate

gahhh depressing :frowning:

Thanks mcgrailm! That’s weird, but effective. I tried your suggestion two or three times and it didn’t work, and I was about to post my response saying “thanks, but it’s not working.” Then I decided it try it one more time, and it worked, and it worked again and again and now it won’t fail. Not sure how you came up with that, but I appreciate it! (Strange about the first few attempts though…)

  • Dan

Well, it’s another day, mcgrailm, and unfortunately it’s a day that it’s not working now - still getting the timeout error. I’m sure you’re right - whatever the eventual solution to this is will be some nutball permutation of commands that works except on Tuesdays unless the temperature falls below 50°F or something.

Dan,

ok… heres a little more demanding version


ignoring application responses
	tell application "QuarkXPress" to activate
end ignoring
delay 5
repeat
	tell application "System Events"
		if frontmost of application process "QuarkXPress" then exit repeat
	end tell
	ignoring application responses
		tell application "QuarkXPress" to activate
	end ignoring
end repeat


This is looking good so far…thanks! I’ll try to pound it today but it won’t be until tomorrow at work when I can really give it a workout from the server.

Much obliged, mcgrailm!

is that script working for you I’m actually planning on putting it in on my scripts so wanted to see how it was going for you ?

The part you’ve supplied is working beautifully, and I wouldn’t have gotten this far without it. Needless to say, now that I’m beyond that there are further Quark peculiarities I have to deal with, but this has been very reliable.

I had to play with it just a little by placing the first part in a repeat loop of its own, because sometimes when it reached the System Events repeat loop Quark wasn’t running (?). The log message in the try/error section was just for my curiosity, and occasionally it does error there but recovers gracefully in the next loop iteration.

Thanks again, mcgrailm.

			repeat
				try
					ignoring application responses
						tell application tQuarkPath to activate
					end ignoring
					delay 5
					exit repeat
				end try
			end repeat
			
			repeat
				tell application "System Events"
					try
						if frontmost of application process "QuarkXPress" then exit repeat
					on error errmsg number errno
						log("error waiting for Quark to come to front: (" & errno & ") " & errmsg)
					end try
				end tell
				ignoring application responses
					tell application tQuarkPath to activate
				end ignoring
			end repeat