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

DeDMakar

macrumors member
Original poster
Mar 24, 2008
39
0
HI!!!
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?
 
Two questions...

Cocoa/Carbon/Java?
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.
 
Sory!!!
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.