Listen for events from other Cocoa Applications
Is there any way to (in Cocoa) listen for specific, generic events occurring in other concurrently running applications? That is to say, can I listen for when another application open, saves, closes, quits, etc? Do Mac applications broadcast a certain set of generic events that I can listen for?
Alternatively, if my application is not in focus, could I listen for certain key-stroke commands, like cmd-o (for open), cmd-s (for save), cmd-w (for close), cmd-q (for quit开发者_运维知识库), etc, as a backend way of listening for events in other applications?
If you want something simpler than distributed objects (suggested by Neilvert), you could use distributed notifications from the distributed notification center. However, these are not posted unless you built the application. For monitoring when applications start or quit, you can use NSWorkspace and its notification center. These notifications are sent for every application which appears in the dock.
You may want to consider Distributed Objects. See reference link here.
精彩评论