• 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: System Events Info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Events Info


  • Subject: Re: System Events Info
  • From: Andrew Oliver <email@hidden>
  • Date: Tue, 10 May 2005 11:10:10 -0700

On 5/10/05 10:27 AM, "Mark Thomas" <email@hidden> wrote:

> As this seems like the route to close a window. How would I get a list of
> all window the finder has open,

It's easier than you think:

 tell application "Finder"
   set theWindows to (get every finder window)
 end tell

(note that I used 'finder window' rather than the generic 'window' since
that takes care of non-browser windows such as Get info, preferences, etc.)

> and then just close the ones which has a
> path starting with "/Volumes/Dev". I have seen there is an attribute called
> path, so I guess I can use that, but what about getting the list of open
> windows and iterating them ??

There are numerous approaches. One, like you say, is to get them all and
iterate through them:

 tell application "Finder"
   set theWindows to (get every finder window)
   repeat with eachWindow in theWindows
      if (target of eachWindow as text) contains "Volumes:dev:" then
         close eachWindow
      end if
   end repeat
 end tell

Note the 'repeat with <object> in <list>' construct which is an easy way to
iterate through a list.

Here 'target of eachWindow as text' gets the Mac-style path to the window.
If you don't coerce it to text you get something like 'folder "blah" of
folder "blahblah" of disk "blahdeblahdeblah" of application "Finder"' which
is much harder to parse.

Andrew
:)

 _______________________________________________
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

References: 
 >Re: System Events Info (From: Mark Thomas <email@hidden>)

  • Prev by Date: Compiled script and high CPU %
  • Next by Date: Zoomed window bug in Tiger?
  • Previous by thread: Re: System Events Info
  • Next by thread: Re: System Events Info
  • Index(es):
    • Date
    • Thread