Application to open changes if another version of that app is open.

This is mainly in regards to Illustrator, however I imagine it will be the same for any app which has more than one version still on the computer.

I have written several Illustrator CS scripts. We still have Ill 8 installed also. If Ill 8 is open and even if CS is also open, the script changes the tell app “Illustrator CS” line to tell app “Adobe® Illustrator 8.0.1” and of course all comands (which were not available for 8) are then corrupted. This happens even if the script is saved as an app. It reverts back to what it is supposed to be after quitting 8, but is there a way to prevent this from happening? Why does it change the app?

Thanks to all.

PreTech

shot in the dark…
try this…

set myapp to "Illustrator CS"
tell myapp
do whatever
end tell

You know, I tried that. Unfortunately when you try to compile the script it doesn’t understand the commands that are Illustrator specific. I just don’t understand why it changes the application referenced. It seems that it should look for the app you want to use and if it can’t find it then throws an error.

PreTech

Try a using terms from block, PreTech:

set Illustrator to "Illustrator CS"
using terms from application "Illustrator CS"
	tell application Illustrator
	” application statements here
	end tell
end using terms from

Another trick that might help in this type of situation is to specify the full path to the target app:

set Illustrator to (path to applications folder as Unicode text) & "Illustrator CS.app"
using terms from application "Illustrator CS"
	tell application Illustrator
		-- application statements here
	end tell
end using terms from

Thanks Kai,

This is what I came up with using your suggestions.

set Ill to (path to applications folder as Unicode text) & "Adobe Illustrator CS:Illustrator CS.app"
set oldIll to "MacIntosh HD G52:Applications (Mac OS 9):Adobe Illustrator® 8.0:Adobe Illustrator® 8.0.1"
try
	tell application oldIll to quit
end try
using terms from application "Illustrator CS"
	tell application Ill
		activate
		
		set docRef to make new document with properties {color space:CMYK}
		make new rectangle in current document with properties {name:"sq1", position:{200, 400}, fill color:{class:CMYK color info, cyan:75, magenta:20, yellow:100, black:0}}
	end tell
end using terms from

Interestingly, when I copied the above script and pasted it in here I didn’t realize that I had CS closed and 8.0.1 open. The using terms from line was changed to “Adobe® Illustrator 8.0.1” This must have something to do with the fact that when you script CS you the app needs to be open. I saved the above as an application and only had 8.0.1 open and it worked.

I do have another question, however. I used this script on CS and it worked:

tell application "System Events"
	if (visible of application "Illustrator CS") is true then tell application "Illustrator CS" to quit
end tell

but if I substitute “Adobe® Illustrator 8.0.1” for CS in the script it errors with “true” being highlighted saying it can’t make some data into the expected type. I’m assuming that this has something to do with 8.0.1 being a classic app. Is there a way to do this with a classic app?

Thanks.

PreTech

This may just be down to a little confusion over the precise target, PreTech. Some applications (from your observations, Illustrator CS - and Finder, for example) have their own visible property. Most don’t. To get the visible property of almost any application process within a System Events tell block, you really need to specify: process “xyz”. (Should work with Classic apps, too.)

However, I’m not entirely convinced that ‘visible’ is the best property to test for in this situation - given that normally visible apps can be hidden manually. So, personally, I’d try testing for the existence of the process (the following is untested):

tell application "System Events"
	if exists process "Adobe® Illustrator 8.0.1" then tell application "Adobe® Illustrator 8.0.1" to quit
end tell

Thanks again Kai.

I did try something along those lines but I was thing “active” instead of “exists” (which of course doesn’t work).

PreTech

P.S. By the way, I did not think the visible would work. I purposely hid Ill 8 but it still made it quit anyway. Hummm. . .? But of course I always seem to have strange effects on electronic equipment.

Here is some code I use to tell which version of PS is currently running so I can address the correct version. You may be able to tweak it for your script. If CS4 is open, it will address CS4, otherwise it defaults to CS3. This script also attempts to open the app if PS is not running. Cheers!



try
		get application process "Adobe Photoshop CS4"
		set photoshopVersion to "Adobe Photoshop CS4"
	on error
		try
			get application process "Adobe Photoshop CS3"
			set photoshopVersion to "Adobe Photoshop CS3"
		on error
			try
				do shell script "open -a \"Adobe Photoshop CS3\""
			on error
				try
					do shell script "open -a \"Adobe Photoshop CS4\""
				on error
					display dialog "Please open Photoshop."
					return
				end try
			end try
		end try
	end try

using terms from application "Adobe Photoshop CS4"
	tell application photoshopVersion

	end tell
end using terms from