Re: System Events Info
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