I have an AppleScript app which is launched when one of it’s data files is “double-clicked” from a spotlight search. This is because I’ve set the script as the default for the datafile. The script then needs to tell the Finder to open the datafile using “TextEdit” rather than the default app. This appears to cause the AppleScript app to be launched a second time despit explicitly saying which app to use for invocation. (Think is has something to do with Finder being involved).
I’ve two options that I can see…
The first is to prevent the second launch by setting LSMultipleInstancesProhibited via the launch Services, so that the second instance fails. This seems a bit messy.
The second is to use the on run handler (or something like that) to sense the second invocation and silently return.
There may well be more options.
Can anyone give me a bit of advice on this and perhaps even a code snippet? I’m a bit new to AppleScript, so I don’t know the standard way of handling this.