activate an application created by a script

Hi there,

I am trying to write a script that does the following:

  1. activate an application ‘app-i’
  2. run a command in this application (using typetext)
  3. the application then saves itself (dumps an image) as app-i+1
    appi+1 thus is an executable application, in the same dictionary as app-i
  4. the script should now activate app-i+1

steps 2,3 and 4 are to be repeated n times.

My problem i that applescript wants to know the location of app-i+1. It throws up a directory window (correct directory), asking me where app-i+1 is.

How do I avoid this window being thrown up, as the whole point of the thing is to automate the process of running, saving and running the application?

I’ve tried hard coding the path name into the name of the application to be opened, but I still get the same window (but now it asks me where HD:application:…:app-i+1 is.

One thing I considered was to try and script the directory window (using type-text), but the window is ordered alphabetically (rather than date modified), so I can’t simply press enter.

Am I pushing the bounds of the activate application syntax here, or am I overlooking something?

Cheers,

Daniel

If this doesn’t work:

tell application "path:to:whatever+i" to activate

You can still try this:

tell application "Finder" to open "path:to:whatever+i"

No luck I’m afraid. Option 1 still throws up the window.

Tell application “finder etc” gives me an “Finder got an invalid key form” error.

any other suggestions?

Cheers,

Daniel

Maybe?:

tell app "Finder" to open alias "path:to:whatever"

If you are sure that it does exist such item, the Finder should open it… Try this variation:

try
     alias "path:to:whatever"
on error
     error "path:to:whatever DOES NOT EXIST"
end try
tell app "Finder" to open result

If you get the error “path:to:whatever DOES NOT EXIST”, perhaps you must wait a little before attempting to run the new item, use “delay 1” or whatever needed…

Cheers for that.

It appears the delay statement does the trick (now even works with activate). So, I guess I will have to adjust the script to watch the folder for the new file to appear. (The running time is going to vary from 10 secs to half an hour). I’m sure I can figure that out.

BTW: does anyone know of an online source which lists the applescript commands?

I saw one the other day, but can’t find it anymore, and it’s a bit hit and miss to try and guess the syntax/commands

daniel

Here is a copy of the AppleScript Suite, which you can open in your script editor and browse just as any application dictionary (22k):
http://homepage.mac.com/julifos/applescript_suite.sit

Cheers… :wink:

Thanks :smiley: