Re: Better way than GetNextProcess()?
Re: Better way than GetNextProcess()?
- Subject: Re: Better way than GetNextProcess()?
- From: Ron Fleckner <email@hidden>
- Date: Wed, 23 May 2007 12:07:17 +1000
On May 22, 2007, at 2:32 PM, Kam Dahlin wrote:
I have a background only app that I need to be able to check to see
if it is running. I have been looking for some nice simple cocoa
calls for this, and [[NSWorkspace sharedWorkspace]
launchedApplications] looked like the way, but it doesn't show
hidden apps. In my research I have run across GetNextProcess() and
it seems to be able to do what I want. However, it is going to be
a bit more involved so before I go and make that call work I wanted
to ask here if there was a better way for getting a list of running
applications, including those that are hidden?
Kam,
AppleScript does a fine job of this:
tell application "Finder"
activate
set processList to do shell script "ps -cx"
set AppleScript's text item delimiters to {return}
set processList to every text item of processList
set AppleScript's text item delimiters to ""
end tell
Then you just need to get processList into an NSArray and ask it if
it contains your process name. Alternatively, run 'ps' as an NSTask
with args 'c' and 'x'
Ron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden