what syntax should be used to launch or activate an application from a variable?
ie if my application is a variable contained within the field “name” of a record called “this_record”
can I do something along the lines of:
tell application (name of this_record)
activate
end tell
I don’t think number of fields is related to your problem… Maybe System Events… Could you post your entire code?
To “activate” an app via System Events you can use anything such as:
tell app "System Events"
tell process whatever
set frontmost to true
end
end
jj & Rob
thanks so much for responding to my posts
somebody contacted me off list and spotted that
I had called System events too many times
seems to work now
thanks again
Sorry to piggy back on this but I think it’s related…
I’m trying to perform a tell by variable aka double tell as described in the " Tell By Variable (herein of the Double-Tell) by Bill Cheeseman " and " Launch By Creator or Identifier by Bill Cheeseman " tips. Only problem is the example provided specifically calls the “Finder” application within the tell by variable so it seems to me that it’s negates the original tell?
I run into issues in my implementation because I’m unable to specify the application by name. Long story short is that I’m writing a droplet that will convert an Adobe InDesign doc to an EPS file. But I need to be able to support multiple versions of InDesign, the default install uses versioning in the name “Adobe InDesign CS2,CS3,CS4,etc”.
So I thought that the tell by variable would resolve this by effectively pulling the .app name from the bundle id “com.adobe.InDesign”
Starting with this… everything works fine…
tell application “Finder” to set appName to name of application file id “com.adobe.InDesign”
tell application appName
activate
end tell
The installed version of InDesign opens without issue. But in the script, I don’t have access to the library for InDesign when opening by reference. So the rest of the code which is related to exporting the EPS won’t compile… example below…
tell application “Finder” to set appName to name of application file id “com.adobe.InDesign”
tell application appName
activate
open (oneFile as alias) without showing window
--create EPS export preferences
tell EPS export preferences
set bleed bottom to 0
.... etc
The first error is on the “window” keyword at the end of the open line. It says “Expected “end of line, etc.” but found “class name”.”
Any help you could provide would be greatly appreciated.
If you want to activate by reference, you have to use a “using terms from” – “end using terms from” block around the instructions that need the dictionary reference from the referred to app.
Sorry if this is a dumb question but doesn’t the “using terms from” command require a version specific app name? (“Adobe InDesign CS2” in my case)
I need this to be dynamic and have been unable to compile when attempting the following ways…
using terms from application file id “com.adobe.InDesign”
using terms from application appName ← this is defined in my initial post ***
I’m trying to get away from having to install all 3 supported version of InDesign on my machine and hard code some nasty control statement in order to compile this app.
Addition: is it possible to just obtain the libraries from the 3 versions of InDesign and package them as Applescript Addons to distribute with the app?
“using terms from” must have the name of the application in it – you can’t use a variable there.
I think you’ll have to ask the user of your script to choose from a list of possible app versions for his machine. If you don’t want to do that, you’ll have to test for the appropriate version in your script, using the shell’s find or better, mdfind. For the latter as an example, here’s a search for the Adobe Reader, blank if not found, or the path if found:
set Rdr to (do shell script "mdfind -onlyin / 'kMDItemCFBundleIdentifier == \"com.adobe.Reader\"'")
--> "/Applications/Adobe Reader 8/Adobe Reader.app" on my machine
You’ll have to have access to each to discover what their kMDItemCFBundleIdentifiers are. Do that with this script, perhaps:
set B to (do shell script "mdls " & quoted form of POSIX path of (choose file with prompt "Choose adobe InDesign application on this machine."))