• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Window Processes Running....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window Processes Running....


  • Subject: Re: Window Processes Running....
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 3 Nov 2005 14:02:22 -0800

On Oct 31, 2005, at 2:22 PM, Martha I Espinosa wrote:

I know this question has come up before but I didn't find the answer... anyways, the answer I want :-)

Using do shell script, how do I figure out what window processes are running? I know how to do this using system events and finder but is there a unixy way of doing this?

Maybe. Clarify what you mean by a "window process" -- did you mean a process that has UI, shows up in the Dock, and so on, as opposed to some sort of background-only thing? In other words, the things System Events returns when you ask for "every process where it is not background only"?


Assuming that's what you meant, then BSD isn't going to help you directly -- the concepts involved are outside of BSD's bailiwick. You have two options. Well, three, really:

1. Write a shell tool that calls the correct API to figure out this sort of thing. (I have one myself that I wrote for testing purposes a while back.)

2. Fake it by relying on certain details of how applications get launched. If you say "ps -xww" (-x to get processes without a controlling terminal, -ww to print out the entire launch command), you'll notice that the "real" applications all have a "-psn_..." argument, so you can pick them out by saying "ps -xww | grep ' - psn_'". Of course, UI-element processes such as Dock also match, so this isn't exactly what you want, but it's a start.

The extra third option is to simply use osascript(1) to call AppleScript from your shell script, and go ask System Events. Not exactly Unix, but it does work from a shell script.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Selecting Multiple Files
  • Next by Date: Re: Records
  • Previous by thread: Re: Selecting Multiple Files
  • Next by thread: Release notes for AS 1.10.3 (OS X 10.4.3)
  • Index(es):
    • Date
    • Thread