tell application ...CS3 or ...CS4

Hi I am creating a script that needs to be launched with "Adobe Photoshop CS3" or "Adobe Photoshop CS4" depending on what version that user has installed. I wanna make it universal.

How to achieve that?

Thanks

iMac Intel Core 2 Duo 2.16 GHz (late 2006), Mac OS X (10.5.1), Memory: 3 GB - L2 Cache: 4 MB - Bus Speed: 667 MHz

Posted on Dec 6, 2009 1:33 PM

Reply
7 replies

Dec 6, 2009 4:24 PM in response to m4c5i

In Leopard, you can do something like:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
set appName to "Adobe Photoshop CS3"

tell application appName
-- whatever
end tell</pre>

You will need to use a surrounding using terms from statement to let the *Script Editor* know which application to get the terms from, but you can use the version to determine which statements you can use.

I am guessing you are going to be using statements specific to each version, but if you are just wanting to use statements available in both versions, then if they have the same bundle identifier you can use that instead (I don't use Photoshop, so I just guessed at the identifier):

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
set appIdentifier to "com.adobe.Photoshop" -- or whatever

tell application id appIdentifier
-- whatever
end tell</pre>

Dec 7, 2009 4:39 PM in response to m4c5i

When using a variable to hold the application name or id, you need to use a using terms from statement, so that the *Script Editor* knows where to get the terminology when compiling the script. Sometimes you can get away without it if you use standard commands such as launch or quit, but for anything more specific you need to use it.

Is the bundle identifier the same with both versions? If so, you can just use tell application id "com.adobe.Photoshop" - the latest version is usually the one that gets run if more than one version is installed. Otherwise, you will need to do something like the following (the application you are getting the terms from doesn't have to exist on the target machine, it is just used to get the script to compile):


set appIdentifier to "com.adobe.Photoshop"
using terms from "Adobe Photoshop CS4" -- an application on your machine
tell application id appIdentifier
activate
do javascript JavaScript show debugger on runtime error
end tell
end using terms from

Dec 10, 2009 9:34 AM in response to m4c5i

Of course, anything is possible and this may not work, but a lot probably has to do with how the user's Application folder is arranged. If the Photoshop application file is located at the _root level_ of that folder, then the "Option1" or "Option2" portions of the code below should identify the version.

Likely however is that the application file is inside another folder that has "Adobe Photoshop" in its name (although the name will probably be more than just that). So the second part of the script looks for a folder whose name contains "Adobe Photoshop" and then seeks to identify which of the two application file versions exists within that.

If the code below returns a value for AppNameVer_ then that's probably what you're looking for. If not, then: 1) Neither of the two versions (CS3 or CS4) may be installed, 2) There may be more than one folder in the applications folder whose name contains "Adobe Photoshop" (perhaps an earlier version --but that could probably be dealt with), or 3) ?

Paste the following into your script editor and run it; you'll find out quickly enough if it works.


tell application "Finder"
set Option1_ to ((path to applications folder as Unicode text) ¬
& "Adobe Photoshop_CS3")
set Option2_ to ((path to applications folder as Unicode text) ¬
& "Adobe Photoshop_CS4")
if exists application file Option1_ then
set AppNameVer_ to "Adobe Photoshop_CS3"
else if exists application file Option2_ then
set AppNameVer_ to "Adobe Photoshop_CS4"
else
set AP_ to name of every folder of folder ¬
(path to applications folder as Unicode text) ¬
whose name contains "Adobe Photoshop"
end if
set Option3_ to ((path to applications folder as Unicode text) ¬
& item 1 of AP_ & "Adobe Photoshop_CS3")
set Option4_ to ((path to applications folder as Unicode text) ¬
& item 1 of AP_ & "Adobe Photoshop_CS4")
if exists application file Option3_ then
set AppNameVer_ to "Adobe Photoshop_CS3"
else if exists application file Option4_ then
set AppNameVer_ to "Adobe Photoshop_CS4"
end if
end tell

Dec 12, 2009 6:49 PM in response to Noaks

I just noted that the code I gave before was somehow altered in transmission. I don't have time to think about the effect of the modification, so I'm re-posting the code (it too might get altered).
The alteration was this:

When it was posted, "Adobe Photoshop CS3" was changed to "Adobe Photoshop_CS3" with an added underscore. This also applies to similar lines containing "CS4." Not immediately sure why this happened or what its effect would be. I'll post the replacement without tags (and it may be awkward to work with):

tell application "Finder"
set Option1_ to ((path to applications folder as Unicode text) ¬
& "Adobe Photoshop CS3")
set Option2_ to ((path to applications folder as Unicode text) ¬
& "Adobe Photoshop CS4")
if exists application file Option1_ then
set AppNameVer_ to "Adobe Photoshop CS3"
else if exists application file Option2_ then
set AppNameVer_ to "Adobe Photoshop CS4"
else
set AP_ to name of every folder of folder ¬
(path to applications folder as Unicode text) ¬
whose name contains "Adobe Photoshop"
end if
set Option3_ to ((path to applications folder as Unicode text) ¬
& item 1 of AP_ & "Adobe Photoshop CS3")
set Option4_ to ((path to applications folder as Unicode text) ¬
& item 1 of AP_ & "Adobe Photoshop CS4")
if exists application file Option3_ then
set AppNameVer_ to "Adobe Photoshop CS3"
else if exists application file Option4_ then
set AppNameVer_ to "Adobe Photoshop CS4"
end if
end tell

Message was edited by: Noaks That looks ok. Give it a try.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

tell application ...CS3 or ...CS4

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.