Separate names with a comma.
Discussion in 'Mac Programming' started by DeDMakar, May 15, 2008.
How can know a program is started? and How can catching keydown event? Thanks...
Seeing as the question was posted by a lolcat, perhaps a "oh hai der! im in ur computer execing mah instrukshuns!" popup would be appropriate?
What app are you trying to know about? If it is yours, you know it started when the code starts executing in main(). If it is a fork(), then the return value of fork() lets you know which one you are in. If it is another app, there are a couple methods you can take.
Cocoa, Obj - C.
How can know a another program is started? I check if is started loginwindow.app
And it is possible to catch event that loginwindow.app was closed? Give me example, please.
Are you starting the process from your program? Then the pid returned from fork() whatever Cocoa fork() wrapper is what you want to know. But I'm assuming that if you know how to spawn processes, you know how to check to see if they're started.
If you're *not* starting the process yourself, you can always do a popen on a 'ps -ef | grep program name you're looking for' shell command.
Yes, that's clear, but how to get this list? I have found 2 ways: ps -ef and [[NSWorkspace sharedWorkspace] launchedApplications]. 1 way shows in the list loginwindow.app, when it's on and doesn't work. 2 way doesn't show this application at all. What would you suggest?