0

Ok. It is 2015. A lot of things have changed. And I would like to ask...

Does anyone know the way to detect how the application was launched on OSX ?

Because I still don't have the answer...

I am talking about these cases that are important to me:

  1. Regular launch by user (via selecting app from Finder, Launchpad, etc.)
  2. Launch at login (automatic launch by myHelperApp on startup)
  3. Launch by user selecting item in services menu ("Do something in MyApp") assuming my app wasn't launched before.

Right now I am detecting the launch-at-login with outdated GetCurrentProcess function, obtaining current process id and then looking up for a parent process info. In case parent process info is obtained (!) and bundleId is not equal to some list of strings (myHelperApp bundleId, com.apple.loginwindow, com.apple.coreservices.uiagent) (!) - then this is not launch-at-login case.

Yes, it works for now, but c'mon people, this is a completely outdated, not stable way to solve the problem!

And what is important - there seems to be no way to tell that my app was launched via Services menu!

Has anyone found something new on this topic?

UJey
  • 1,442
  • 11
  • 15
  • `getppid()` will get you the ID of the parent process, which may be a start. – JWWalker Jul 22 '15 at 15:12
  • Thanks. But getting parent process id is not a problem. It is still a big problem to know how the app was launched. – UJey Jul 23 '15 at 16:08

0 Answers0