Re: Minimize all windows of an application?
Re: Minimize all windows of an application?
- Subject: Re: Minimize all windows of an application?
- From: kai <email@hidden>
- Date: Wed, 16 Feb 2005 02:33:08 +0000
On Mon, 14 Feb 2005 18:54:12 -0500, Kevin Smith
<email@hidden> wrote:
I can't seem to figure out how to minimize all the windows of an
application. I thought that the following command would work, but I
just get an error.
tell application "System Events"
set myapp to the name of the first process whose frontmost is true
set mywindows to every window of application process myapp
repeat with i in mywindows
set collapsed of i to true
end repeat
end tell
Playing 'digest catchup', I don't recall seeing any suggestions on this
yet, Kevin - so I guess you're stuck with me...
Apart from initially getting the name of the frontmost process, I
suspect you'd be better off addressing the target application directly,
rather than as a process of System Events. In addition, while the
windows of some applications may have a 'collapsed' property, others
are 'miniaturized'. One way around this is to test for either
possibility.
The good news is that you shouldn't need a repeat loop:
--------------------------------
tell application "System Events" to set myApp ¬
to name of first process whose frontmost is true
tell application myApp to try
set «class wshd» of windows to true (* collapsed *)
on error
try
set «class pmnd» of windows to true (* miniaturized *)
end try
end try
--------------------------------
The reason for the raw codes («class wshd» & «class pmnd») is to avoid
application-specific references at compile time. The script won't know
exactly which application it is addressing until runtime, when System
Events attributes a process name to the variable 'myApp'.
That said, one or both raw codes may automatically compile as
'collapsed' or 'miniaturized' respectively. (The latter is more likely
to compile than the former.) If we entered the words 'collapsed' and
'miniaturized' in place of the raw codes, and they weren't recognised
as application keywords at compile time, then they might be wrongly
interpreted as variables.
HTH
---
kai
_______________________________________________
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