Re: Minimizing non-Frontmost Windows
Re: Minimizing non-Frontmost Windows
- Subject: Re: Minimizing non-Frontmost Windows
- From: Nigel Garvey <email@hidden>
- Date: Fri, 21 May 2004 18:19:20 +0100
Irwin Poche wrote on Fri, 21 May 2004 07:42:48 -0500:
>
On May 20, 2004, at 11:17 AM, Nigel Smith wrote:
>
>
> ----------
>
> tell application theApp
>
> repeat with x from (count of windows) to 2 by -1
>
> try
>
> set miniaturized of window x to true
>
> on error
>
> set collapsed of window x to true
>
> end try
>
> end repeat
>
> end tell
>
> ----------
>
True, that's simpler, but the real problem, why it doesn't work in the
>
Finder, remains.
It doesn't work in any app on my system. 'Miniaturized' and 'collapsed'
are keywords of specific applications and will only compile in the
appropriately named 'tell' or 'using terms from' blocks.
The following seems to work for the Finder, Safari, and Script Editor,
and will probably work for any scriptable app that shares the same
property codes as Safari or the Finder:
tell application (path to frontmost application as string)
repeat with x from (count windows) to 2 by -1
try
using terms from application "Safari"
set miniaturized of window x to true
end using terms from
on error
using terms from application "Finder"
set collapsed of window x to true
end using terms from
end try
end repeat
end tell
However, if you run it from the Script menu, System Events will always be
the frontmost application (unless this has changed in Panther). If you
really want this facility, it may be best to write a separate script for
each application where you're likely to need it. This can be placed in a
folder named after the application, in an "Applications" folder in your
"Scripts" folder. The appropriate script will then always be visible in
the Script menu whenever a particular application's frontmost.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.