[Pythonmac-SIG] How to tell if a .app is clicked again?

Nicholas Riley njriley at uiuc.edu
Wed Aug 17 00:07:57 CEST 2005

On Tue, Aug 16, 2005 at 03:02:04PM -0700, Chris Barker wrote:
> Well, it's not, but that is an idea. If I have a little launcher stub, 
> it could just check and see what's running, and then launch what it 
> needs to, then quit. That way it would just get started up again if the 
> user double clicked again, and then do what it needed to. That would 
> require more than one app to be installed, however.
> Which leads me to another idea: Can I tell OS-X that I DO want another 
> instance of the app launched rather than raising an existing one? That 
> way, I could do the Windows trick: On launch, check for an existing one, 
> of it's there, start the browser and quit. If it's not, start the 
> server, then the browser, and don't quit. This would let me have the app 
> and the "launching stub" be the same app.

You can do this (LaunchServices lets you multi-launch apps, or you can
always execute the binary directly), but not from the Finder.
However, you could do something slightly different, and closer to your
first idea: embed the actual app inside the launcher app's
bundle. Then start your real app, with an icon or not, when the
launcher app runs; the launcher app would then exit.  If the launcher
app notes that the real app is already running, then just open the
page in the browser.

The user would only see one app, and since the Finder in OS X no
longer shows apps differently when they're open, they'd never know the

Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>

More information about the Pythonmac-SIG mailing list