Adobe Illustrator CS6 tell application reference

Does anyone out there know how Applescript (2+) determines the application’s name for tell blocks?

For example; consider: (all from CD’s paste tell, but issue the same in Script Editor or osacompile)

tell application “Adobe Illustrator”
#~-- your Adobe Illustrator CS6.app code goes here~#
end tell
tell application “Adobe InDesign CS6.app”
#~-- your Adobe InDesign CS6.app code goes here~#
end tell
tell application “Adobe Photoshop CS6.app”
#~-- your Adobe Photoshop CS6.app code goes here~#
end tell

Note Illustrator does NOIT include the “CS6.app”, and if “I” key it in the subsequent compile goes to “Browse for it” mode and removes it.

My guess is for scriptable apps the “tell” name is in the app’s bundle info.plist, but editing that file is a no-nno & makes Illustrator fail, so I can’t prove it that way.

This is a non-trivial issue for a site that has more than one version of Adobe CS6 apps active.

I don’t know exactly how AS determines it, but using the more modern id reference (tell application id “com.adobe.InDesign”) should resolve this problem and other potential ones. Occasionally, Adobe apps won’t even recognize their own scripting commands and objects unless I use this type of tell block.

Fortunately, you can change the default for new tell blocks in SD under Preference>Editor “Reference applications by ID when pasting tell blocks”.

SD also puts in a comment including the name of the app when the tell block was inserted. Very handy!

Ray

For some apps (pages) I use "tell application "

Thanks for the ideas. I have not tried the ID form, I will experiment with it.

Wouldn’t the Id be ambiguous if you have both CS5 and CS6 in your system? My client has and that is my concern … but adding CS5 and CS6 to the tell statement deals with that.

The scripts should default to whichever version is open.

I have Adobe Illustrator CS6 so I tried this out.

This is a strange problem. When I tried compiling “Tell block 1” shown below the tell application “Adobe Illustrator CS6” was changed to tell application “Adobe Photoshop CS6” and “Adobe Photoshop CS6” launched to compile the tell script

-- Tell block 1
tell application "Adobe Illustrator CS6"
	name --> This returned the name "Adobe Photoshop CS6" when the script was ran
end tell

but when I used “Tell block 2” I hand no problems compiling and ended up withe a tell block for “Illustrator CS6”

-- Tell block 2
tell application "Bills second iMac HD:Applications:Adobe Illustrator CS6:Adobe Illustrator.app"
	name --> This returned the name "Adobe Illustrator" when ran
end tell

Tell block 2 created a reference to the correct application and launched Illustrator CS6 to get the dictionary info. For some reason you now have to specify the actual path to the application for Illustrator CS6. It didn’t use to require that. Perhaps one of the later system updates messed it up.

Bill

Yes, indeed, putting the full path name makes sure the desired version of an application is selected. I use that method during testing of scriptable applications be be sure that the correct “build” binary is selected.

Using the now accepted POSIX form of path makes it more system portable If the script needs to run on multiple machines. POSIX example:
tell application “/Applications/Adobe Illustrator CS6/Adobe Illustrator.app”

The “bad” side of this is that all the target systems must install Adobe Illustrator with the same name and location; but that is not a problem for most sites I work with.

This is not uniquely an Adobe Illustrator issue. I wonder is someone knows HOW Applescript matches the “generic” tell reference to the application bundle.

ksteff,

I was thinking today about your Illustrator problem. Finding the name of the Illustrator version on your clients disk using AppleScript is pretty easy if the application is running. I am assuming either you need the AppleScript when you personally visit a site or the clients run it. But if the clients run it they must know the name of the App to launch it at their business site. So it seems reasonable to give you way to find the running App even if you don’t know the name or where it is on the disk.

So what I did was create a functional script that does just what you wanted. It tells you the name and the path in a dialog. Using the script you should be able to incorporate that into your script. The method is pretty quick. I only have to search through a list of running user apps to find it and that’s quick. Finding an application with an unknown name in an unknown place on the disk is more of a problem because that is slow.

I stuck the application path in an edible text field in the dialog that comes up in case you wanted to copy it for some reason. The script puts up an error dialog if 2 or more Illustrator apps are found, or if no apps are found. I wouldn’t think that would be a problem. But if they have 2 different versions of the app running at the same time that would cause the script to put up an error dialog and quit. The script could be extended to handle different versions running at the same time. But it seemed pretty unlikely.

Here is the script:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set AppName to ""
set AppPath to ""

tell application "System Events"
	set AdobeIllustratorAppID to "com.adobe.illustrator"
	
	set IllustratorList to (every application process whose bundle identifier = AdobeIllustratorAppID)
	set NumItemsFound to count of IllustratorList
	if (NumItemsFound = 0) then
		display dialog "No applications with ID \"" & AdobeIllustratorAppID & ¬
			"\" are currently running." with title "Error" buttons {"OK"} default answer AdobeIllustratorAppID
		return false
	else if (NumItemsFound > 1) then
		display dialog (NumItemsFound as text) & " applications with the ID \"" & ¬
			AdobeIllustratorAppID & "\" are currently running." with title "Error" buttons {"OK"}
		return false
	else if (NumItemsFound = 1) then
		set ApplicationProcess to item 1 of IllustratorList
		set AppPath to path of application file of ApplicationProcess
		if (AppPath ends with ":") then set AppPath to strings 1 thru -2 of AppPath
	end if
end tell

tell application "Finder" to set AppName to name of (item AppPath)

tell me to display dialog "An application with the name \"" & AppName & "\" and ID \"" & AdobeIllustratorAppID & ¬
	"\" was found.  The path is listed below." with title "Application found" buttons {"OK"} ¬
	default button "OK" default answer AppPath

Bill