Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Application Launch Event

Tags:

macos

cocoa

Is there a way to somehow hook into the system event of an Application Launch in Mac OS X? For example, let's say that I want a simple script or program to run each time a specific application is opened. I'm hoping that there is some sort of Cocoa API to do this, but I have not found one yet.

like image 659
dkaranovich Avatar asked Dec 31 '25 01:12

dkaranovich


1 Answers

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

like image 128
dkaranovich Avatar answered Jan 03 '26 13:01

dkaranovich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!