I woud like to have a script that tells my AS Studio application to perform a subroutine
It came to something like:
tell application “myApplication”
SEARCH_FOR_APPLICATIONS()
END__OF_JOB()
quit
end tell
This results in an error. but it must be possible.
I looked in the dictionary but cannot find the statement to summon the application to perforn a certain task (subroutine)
My solution to this problem (don’t know if there is a better one) it to use hidden buttons. Place a hidden button on some window that calls your subroutine when clicked. That subroutine can then do its thing and (if desired) return a result.
You can call the subroutine externally with a line like:
tell application “app name” to tell button “button name” of window “window name” to perform action
set the_result to the result
I am developing an AppleScript Studio application, that also includes a couple of separate AppleScripts that can be used to control the application without opening it directly. I have been happily using the above-mentioned method in the scripts. However, I recently open sourced the application, and for this reason changed the script files from compiled scripts (.scpt) to text files (.applescript) for better functionality with Subversion.
This leads to one problem. Now the scripts are compiled at build time, and if the application is missing, the build fails, because the scripts contain the tell application “app name” block. I tried to solve this by using this kind of syntax:
set myapp to “app name”
tell application myapp to tell button “button name” of window “window name” to perform action
But as that is not plain vanilla AppleScript, it does not work. So, I tried this:
set myapp to “app name”
using terms from application “app name”
tell application myapp to tell button “button name” of window “window name” to perform action
end using terms from
But again, if the application is not present at build time, it fails. One solution is to use this:
using terms from application “Xcode”
which works on my computer, as I have Xcode installed, but probably leads to problems on machines that do not have it.
So, is there a solution to this problem that would both allow the application to be compiled without the need of the application to be present already, and also for the compiled application to work on machines without Xcode?