[launchd-dev] Running my application on event: another application's start

Quinn "The Eskimo!" eskimo1 at apple.com
Mon Oct 4 03:13:21 PDT 2010


On 3 Oct 2010, at 15:14, eveningnick eveningnick wrote:

> "Who" in OS X can give me a notice, that a new process with name
> "Microsoft Word" has been launched?

There's no way you can achieve your goal directly; you will have to run all the time and watch for the app being launched.  However, there are easy ways to achieve both of those steps:

o As long as your running in the same GUI login context as the target application, you can hear about its launch via NSWorkspace (specifically NSWorkspaceDidLaunchApplicationNotification).  On older systems you can use Carbon Events (kEventAppLaunched) to achieve the same results.

o The best way to ensure that you're running in the correct context is to install yourself as a GUI launchd agent.

See Technote 2083 "Daemons and Agents" for background information about the above.

<http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html>

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware




More information about the launchd-dev mailing list