Using AppleScript...

Discussion in 'Mac Programming' started by ethan-1878, Sep 11, 2015.

  1. ethan-1878 macrumors member

    Jun 8, 2014
    Hi all,

    I'm using an AppleScript app to launch apps in a managed fashion rather than having lots of apps in my "Login Items". My problem is that within that app, I'm launching another AppleScript app (the second one mounts a server for work into Finder, lets call it the 'mounting app') but it doesn't mount if I launch the app through AppleScript.

    I know that I can just tell the launching app to mount the server while it is opening all of my apps BUT my plan was to make separate 'Quick Launch' apps for work and home etc. so it's a bit of a pain having to recompile my other 'Quick Launch' apps just because of the issue with the 'mounting app'.

    If anyone knows why this is happening, I'd appreciate any help you can offer me.


  2. Mark FX macrumors regular

    Mark FX

    Nov 18, 2011
    West Sussex, UK
    The problem your having is most likely to be that AppleScript is a single threaded language.
    This means that only One instance of AppleScript can be running at any One time.
    So your calling App is running AppleScript code, and your mounting App is also trying to run AppleScript code.
    So one or the other of the App's is not executing.

    You can try running a delay in the calling App, and also checking that the mounting app has completed before continuing any code in the calling App.
    This may not work, and the delay time could be guess work, or be a trial and error process.

    What version of OSX and AppleScript are you using ?

    I tend to use the AppleScriptObjC language myself these days, this allows me to use the NSObject performSelectorOnMainThread:SEL)aSelector withObject:id)arg waitUntilDone:BOOL)wait method, which can be set to halt the execution of code until the method returns.
    But I've not tried this method with executing an external AppleScript application.
    But could be worth a try.

    Regards Mark

Share This Page