Referenced application launching when opening script?


I have the following script:

set CheckForInternetConnection to (count (get (("" as URL)'s host & {dotted decimal form:""})'s dotted decimal form)) > 0

if (CheckForInternetConnection is not true) then
	tell application "APP_NAME"
	end tell
end if

When I open the script in AppleScript Editor, the application (ie. “APP_NAME”) automatically opens. At first, I thought AppleScript Editor was automatically running code when I opened the script, but I was wrong. But, still, when I open the script, the referenced application (ie. “APP_NAME”).

Does anyone know why this would happen?



To know what’s going on, is maybe a bit strong. But your applicaton is connected to the script by AppleEvents, in order to translate the terminology, AppleScript Editor will open the dictionary, to be able to translate from the scripting terminology application APP_Name uses. But in order to be able to execute your script, I think AppleScript Editor, just launches it, so the script shall execute without any delay, by having the app launch at the least possible moment.

I hope this is both understandable, and correct. :slight_smile:

This fixed the issue. Thanks!


Letting AppleScript/LaunchServices take care of it seems like the perfect solution. I only saw the cause, and didn’t think there was a cure! :slight_smile:

Quit, Print, Launch, Activate and Open are indeed commands you can issue by AppleScript whether the app is scriptable or not.

So what I said above stands, though rather clumisly written, it is for targetted applications, that the editors launch applications. (ScriptDebugger asks you), and I believe they only do that, should they need to use the dictionary to resolve, syntax, which they must do, if the command isn’t one of those mentioned above.

You can also get properties of an application, without launching it, like path by the way.