Application Launch Event Detection

Is there a way to somehow connect to the system event of the application launch on Mac OS X? For example, let's say that I want a simple script or program to run every time I open a particular application. I hope there is some kind of Cocoa API for this, but I haven't found it yet.

+3
source share
1 answer

Ah, I figured it out myself. There's a class called NSWorkspace that contains an NSNotificationCenter that you can add observers too. I added an observer for the name "NSWorkspaceDidLaunchApplicationNotification" and this seems to do the trick.

+5
source

Source: https://habr.com/ru/post/1780784/


All Articles