![]() On error number -609 # 'Connection is invalid' error that is spuriously reported Run application "Macintosh HD:Applications:_Sandbox-AppleScript0.app" You can mitigate this by selectively ignoring only the specific Connection invalid error (which assumes this error would not legitimately occur) : try end try, as suggests - the downside is that you won't be able to detect actual failure to invoke the application. You could use run even with AppleScript-based applications and simply ignore errors with try.Run application ":path:to:applescript:apps:shell-script-launcher.app" to run non-AppleScript apps: use run / activate to run the app hidden / frontmost:.Note: There's also load script file, which indeed lets you merely load script code without executing it right away. Run script file ":path:to:applescript:apps:shell-script-launcher.app" to run an AppleScript-based app: best to use run script file, as recommends - this has the added advantage that the invoked AppleScript-based application can return objects directly to the caller:. ![]() ![]() If you know the type of application you're invoking up front: pragmatic solution simply uses do shell script with the standard open utility to bypass the problem - this should work, regardless of whether the application is AppleScript-based or not:Īlias ":path:to:applescript:apps:shell-script-launcher.app".If the intent is to launch and run in one step, run application is sufficient - no need for a separate launch application command first.On OSX 10.10, behavior is consistent with the documentation, with one thing worth noting: On what OSX version was the app that doesn't execute with launch created? Please let me know if your system behaves differently and/or how older versions behave. Note: I've witnessed the non-executing behavior with launch once, but every non-stay-open AppleScript-based test app I've created from scratch on OS X 10.9.2 and OS X 10.8.5 also executes the script with launch - contradicting what the documentation says. Not sure how OSX versions <= 10.7 behave. Launch by itself is enough to run the application and is indeed the only command that works with AppleScript-based applications.Īny attempt to execute run or activate (whether in addition to launch or not) runs the application - even twice when run from AppleScript editor(! just once with osascript) - but reports failure got an error: Connection is invalid. Broken behavior on OSX 10.8, 10.9 (fixed in OSX 10.10): When the run command is sent to the script application, it processes the command, sends back a reply if necessary, and quits. The launch command launches the script application without sending it an implicit run command. To launch a non-stay-open application and run its script, use a launch command followed by a run command, like this: Here's how Apple thinks it works with AppleScript-based applications, which is only true starting with OSX 10.10 (Yosemite):Ī script can send commands to a script application just as it can to other applications. it is unclear (to me) what exactly that means for non-AppleScript-based applications.for AppleScript-based applications this should mean that they're loaded, but not executed (i.e., their - implicit or explicit - on run handler is NOT invoked), but in practice that is not true up to 10.9 - see below. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |