Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hello developers!

How to close an active application using Mac API(for example QuickTime player) I develop on C/C++, Mac OS X 10.4.8
 
If it has to be C or C++ then you will have to send and AppleEvent to the application in question. This is not all that simple to achieve. It's easier to use AppleScript:

tell application "name" to quit

If you were using Objective C/Cocoa then you could use NSAppleScript.

If it has to be C/C++ then you are probably stuck with the complex and ugly Apple Event Manager

Note that if you are in C it might be easier to shell out and use osascript -e 'tell application "name" to quit' than to use the Event Manager...
 
Robbieduncan, is it possible using AppleScript to catch events from application. For example: If user opens QuickTime player and begin to preroll movie I must know what he do now. Is it possible with AppleScript?
 
Unless the application chooses to send an event then no, there is no automatic way to know when a specific event happens in another app that I know of.
 
Robbieduncan, is it possible using AppleScript to catch events from application. For example: If user opens QuickTime player and begin to preroll movie I must know what he do now. Is it possible with AppleScript?

AppleScript can be recorded off of some applications. Implementing it has always been a pain and with a bunch of changes to make adding scriptability easy, nothing really has been done to make recordability easy.

On possible option is that quicktime movies can trigger actions, but that means you need control over the movie.

You may want to make your own movie player if that is all you looking for. Its fairly easy to do with cocoa and interface builder. Then you can key off of the movie player itself.
 
POSIX signals?

What about sending the process a simple SIGTERM, or if it doesn't need to do any specific cleanup a SIGKILL, i.e.

kill (<pid of receiving process>, 15) //SIGTERM

kill ( <pid of receiving process>, 9); //SIGKILL
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.