In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Ted Zeng) wrote:

> "ps" doesn't list the processes like Illustrator.

Yeah, like Sherm said.

These are the two most common methods that I've used, along with a sort-of
port of JD's AppleScript to Mac::Glue.

   #!perl -wl
   # simple
   print 1 if grep 'Photoshop', `ps auxw`;

   # heh
   use Mac::Glue ':all';
   my $syse = new Mac::Glue 'System Events';
   print 1 if $syse->obj(processes => whose(
      creator_type => contains => '8BIM'  # can't see way to do bundle ID?
   ))->get;

   # my favorite
   use Mac::Apps::Launch;
   print IsRunning('com.adobe.photoshop');

The latter is almost surely your best solution.  No calls to external apps, 
is included with Tiger, and doesn't rely on possibly conflicting paths and 
app names.

It uses Mac::Processes to loop over running applications, and is probably as 
efficient in that regard as the other methods, since they all basically have 
to do the same thing too.  But that it doesn't have to call out to another 
app makes it that much more efficient.

It can also accept a four-char code, in this case, IsRunning('8BIM'), like 
the Mac::Glue code does.

For the Mac::Apps::Launch code to work, you need version 1.90; 1.91 is 
included in Tiger, so you should be fine if you're using that.  Older 
versions of the module can still handle the four-char code syntax.

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Technology Group       [EMAIL PROTECTED]     http://ostg.com/

Reply via email to