I’m REALLY new to applescript and I’m trying to make an applescript to launch an app w/ a particular doc. My application (Navis SPARCS) saves my startup settings in a doc. When I doubleclick the startup doc, it automatically finds the latest version of the app and launches it… however I want more control on versions for rollouts so I want to specify which app to use when launching, e.g., I’ll name the Prod version PROD and the new one awaiting rollout NEWPROD.
I’ve tried
tell Application PROD
open “XXXX:XXXXX:STARTUP.DOC”
end tell
And it seems to launch the application OK, but it macsbugs out upon exit (the application vendor requires we run macsbugs with the app)… and actually Finder seems messed up even before I quit my app. Opening the volume doesn’t show me all the contents. Also, It is not even launching the app with the right settings so its not even “opening” my startup.doc
If I do a
tell Finder
Open file PROD
end tell
that launches the right app correctly, AND it doesn’t macsbugs or mess up finder BUT I need the settings that are found in startup.doc.
I could also do a
tell Finder
Open File Startup.doc
end tell
but it will launch the NEWPROD app every time! Its almost like I need to applescript the drag and drop onto the correct app?
set thisFile to choose file with prompt "Please select the file to open."
set thisApp to choose file with prompt "Please select the application to use to open the file."
tell application "Finder" to open thisFile using thisApp
After I select ThisFile and ThisApp, in my event log I see:
tell application “Finder”
open alias “…START test.nsu” using alias “…”
then my spinning wheel comes on and then I get a “Finder needs your attention”. In order to select Finder tho, I do a command+“.”.
then as soon as I select Finder from my topright list, the app automatically launches. What IS working is that I can tell it is using the document, because it has all right the startup settings, and I’ve tested selecting two different startup settings and its starting up as I selected.
Ok, I am no pro so this may be just worthless to you, but, hey its worth a shot.
Code:
set thisFile to choose file with prompt “Please select the file to open.”
set thisApp to choose file with prompt “Please select the application to use to open the file.”
tell application “Finder”
activate
open thisFile using thisApp
end tell
I don’t know if this will do anything, but I have done this in several scripts and by pulling the Finder to the front, it avoids the need for the cmd+period. Sometimes
the Finder just works better at this kind of thing if it is in front.