Search code examples
serviceapplescriptfinder

Precompiled applescript service?


I have created an automator service for my finder which runs an applescript. I will have to use this service incredibly often. I have noticed that after running the service, there is a very large (about ten second) delay before I receive any popups from the script. This is far too long. I am almost positive this delay comes form automator compiling my script every time it is run....

So, I have a question -- is there a way to pre-compile an applescript, then install that applescript as a finder service? Going through automator was the simplest way I could think of to install my script as a service, but if there is a better way -- particularly one that pre compiles my applescript, that would be great.


Solution

  • I'm not sure if it's a "compiled" issue. I see long delays sometimes too, even with compiled scripts. Automator actions are run by the "automator runner" application and applescripts are run by the "applescript runner" application (unless they're created as stand-alone applications). I notice sometimes that during the first launch that it takes extra time but on subsequent launches it acts faster... maybe because the runner applications are up and running during subsequent runs. So I'm more likely to believe it's something in the runner applications rather than the script itself.

    However you can run a "compiled" script if you wish. Just create the script as a separate file. Then in the applescript portion of your automator action use this...

    run script file "path:to:script.scpt".
    

    With that being said, you can even create the applescript as an application and then run that from automator...

    tell application "MyApplescript" to activate
    

    Maybe one of those solutions will help speed it up for you. If you do achieve a speedup, please let us know.