Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Minimize/unminize all windows in the active application System
Now that it seems increasingly unlikely that Unsanity will update WindowShade X for Snow Leopard, I wanted some kind of substitute. In Snow Leopard, you can minimize (actually "miniaturize") windows to the program's Dock icon (enable this in the Dock System Preferences panel), and you can double-click on a window title bar to do this. Nice and out of the way.

But getting such windows back requires excessive mouse movements. (Either activate Exposé and click on the window, or right-click on the application's Dock icon and select the window by name from a menu. Then you must mouse back up to the window. If you do this constantly, it gets very frustrating and prone to strain.

This AppleScript will either miniaturize all windows in the active (frontmost) application, or un-miniaturize them all. The difference between the two behaviors is controlled by one script property (theval). So create two versions of the script, one with theval set to true (to miniaturize), and one with theval set to false (to un-miniaturize). Here's the "miniaturize" version:
(*
Frontmost miniaturize / unminiaturize
by Wooden Brain Concepts
11-18-2009

miniaturize (to dock) or unminiaturize all windows in the frontmost app.
This works in many but not all applications.
Suggest using it with a keyboard macro program and/or a mapped mouse button, etc.

*)

-- theval = true : miniaturize ; theval = false : unminiaturize 
property theval : true
-- require windows to be resizable?  (default: false)
property requireresizable : false
-- must all windows have a title to unminiaturize only? (default: true)
property windows_must_have_titles : true
--window names to exclude when unminiaturizing only (default: {"Downloads", "Invite"})
property exclusions : {"Downloads", "Invite"}
-- gui scripting main window for these apps (by bundle id) (default: {"com.microsoft.entourage", "ws.agile.1Password"})
property guiscripting : {"com.microsoft.entourage", "ws.agile.1Password"}

tell application "System Events"
  set bi to bundle identifier of (some process whose frontmost is true)
end tell

(*
-- testing only
--set bi to "com.apple.finder"
set bi to "com.apple.itunes"
set bi to "com.apple.systempreferences"
*)

if not theval and (bi is in guiscripting) then
  (*
  this is special handling for some unscriptable apps.  this whole conditional can be eliminated if you don't use it. it requires "Enable access for assistive devices" in Universal Access Preference Pane to be on to enable GUI access scripting. have not yet figured out how to miniaturize to dock.
  *)
  set thisapp to ""
  set theindex to 1
  if bi is "com.microsoft.entourage" then
    set thisapp to "Microsoft Entourage"
  else if bi is "ws.agile.1Password" then
    set thisapp to "1Password"
  end if
  if not theval and thisapp is not "" then
    tell application thisapp to activate
    try
      tell application "System Events"
        tell process thisapp
          tell menu bar 1
            tell menu bar item "Window"
              tell menu "Window"
                if bi is "com.microsoft.entourage" then
                  set winmenuitems to name of every menu item
                  set theindex to 11
                  -- get best guess at main window
                  repeat with i from 11 to (count winmenuitems)
                    if (item i of winmenuitems contains "—") or (item i of winmenuitems begins with "Folders") then
                      set theindex to i
                      exit repeat
                    end if
                  end repeat
                  click menu item theindex
                else if bi is "ws.agile.1Password" then
                  click menu item "Main Window"
                end if
              end tell
            end tell
          end tell
        end tell
      end tell
    on error myerr
      -- log myerr
    end try
  end if
else if bi is "com.apple.itunes" then
  -- special case for itunes :  minimize (mini-player) rather than miniaturize (to dock) the main iTunes window
  tell application "iTunes"
    set minimized of browser window 1 to theval
    activate
  end tell
else
  tell application id bi
    try
      set wins to every window whose closeable is true
      repeat with awin in wins
        try
          if bi is "com.apple.finder" then
            using terms from application "Finder"
              -- finder windows use the property "collapsed" rather than "miniaturized" -- annoying
              if closeable of awin and ((resizable of awin is true) or not requireresizable) and ((theval and visible of awin) or (not theval and (get collapsed of awin) and name of awin is not in exclusions)) and (not windows_must_have_titles or (windows_must_have_titles and name of awin is not "")) then
                try
                  set collapsed of awin to theval
                end try
              end if
            end using terms from
          else
            if closeable of awin and ((resizable of awin is true) or not requireresizable) and ((theval and visible of awin) or (not theval and miniaturized of awin and name of awin is not in exclusions)) and (not windows_must_have_titles or (windows_must_have_titles and name of awin is not "")) then
              try
                set miniaturized of awin to theval
              end try
            end if
          end if
        on error myerr
          -- log if desired
          --log myerr
        end try
      end repeat
    on error myerr
      -- log if desired
      -- log myerr
    end try
    activate
  end tell
end if
Each script can then be attached to a keyboard combo (with a keyboard macro program such as QuicKeys). I have also triggered the scripts with a programmable trackball (using Kensington MouseWorks), so I can perform both actions with the trackball without moving the mouse pointer. (Similar results could be achieved with other mouse drivers, I believe.)

Certain options are definable in the script properties. This script works in many but not all applications, and some workarounds using GUI access scripting were included for MS Entourage and 1Password.

[robg adds: I tested this script in both 10.5 and 10.6, and it works as described in both versions of the OS. As noted, it will not work in all applications.]
    •    
  • Currently 2.53 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (15 votes cast)
 
[9,041 views]  

Minimize/unminize all windows in the active application | 19 comments | Create New Account
Click here to return to the 'Minimize/unminize all windows in the active application' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Minimize/unminize all windows in the active application
Authored by: Geobunny on Dec 03, '09 07:56:23AM

So does command option M (or option and middle/yellow minimise button) not work in 10.6 any more? Admittedly it won't un-minimise all windows, but how often have you ever needed to do that?



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: asmeurer on Dec 03, '09 08:02:47AM

Well, if you are going to minimize all windows, I think it would be nice to be able to unminimize them, yes?



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: bglnelissen on Dec 03, '09 11:57:35PM
I prefer hide (command-h) instead of minimize (command-m). With hide there is also a capability to un-hide (command-h), for me this gives the result I want. By clicking the programs' icon in the dock will also unhide your hidden windows.
Edited on Dec 04, '09 12:04:00AM by bglnelissen


[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: mici on Dec 04, '09 07:09:03AM

Option-click on the “minimize” button hides all windows, Option-click on any minimized window of an application in the Dock expands them all.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: Toadling on Dec 03, '09 10:17:15AM

If you're going to minimize all the windows of an app, why not just hide the app instead?



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Dec 03, '09 10:56:38AM

There are lots of reasons. If you're working with Finder or Path Finder you might want to see or work with items on the desktop. If I'm in Entourage, I want to hide the bulky main window but still create a new mail message and work with that. Also, as I said in the description, I want to mimic, sort of, the flow of Window Shade X. So I can double click on a window title bar when hand is on mouse, rather than going to the keyboard to hide. I can miniaturize not all but some of the windows that way, and then easily get them all back when I want them. (That's a big difference right there.) Plus, this may be a false presumption, but it seems to me anyway that hiding and app and then activating it takes longer as (I think and it seems that), the app hidden often gets written out to VRAM.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: Toadling on Dec 03, '09 05:30:51PM
If you're working with Finder or Path Finder you might want to see or work with items on the desktop.

Hiding Finder or Path Finder works for this, doesn't it (assuming some other app is allowed to be frontmost)? Exposé works too.

I don't have anything against minimizing all your windows, if that's how you like to work, but accessing the desktop doesn't seem like the best reason to do it. But you make some good points and I can understand your motivation. Thanks for the hint.

Plus, this may be a false presumption, but it seems to me anyway that hiding and app and then activating it takes longer as (I think and it seems that), the app hidden often gets written out to VRAM.

I don't think that's true. AFAIK, hiding an app has no impact on memory swapping. On my system, there doesn't seem to be any performance hit either. In fact, hiding seems slightly faster than minimizing, perhaps because there's no animation involved with hiding an app.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: rpaege on Dec 03, '09 11:03:13AM

"Unsanity is still hard at work on Snow Leopard compatibility for the rest of our stuff and will be announcing availability as things become ready. Look for posts from Slava and Rosyna about WindowShade, FruitMenu, FontCard, Labels X, Menu Master, and Xounds in the near future, and watch for something from me about Mighty Mouse."

http://unsanity.org/



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Dec 03, '09 11:08:55AM

yeah, that was posted 2 months ago (Oct 6), and over 3 months since SL was released, with no further information, and no responses whatsoever to anyone from Unsanity support. I wouldn't hold your breath.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: snit on Dec 03, '09 02:44:36PM

I just option+click the minimized window on Exposé or the dock. I thought that was fairly common knowledge... hmmm, I could have submitted a hint. :)



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Dec 03, '09 03:45:51PM

kills me to be so defensive here -- but please read the post. the point is to minimize repetitive stress: moving back & forth from mouse to keyboard and up and down on the screen. windowshade x did that nicely. click on a title bar and you don't need to move far to get it back, or use anything but the mouse. option-clicking requires keyboard and mouse. if you go to expose, that's keyboard and then keybord mouse. going down to the dock is really the part we're tying to avoid here. (and anyway i don't see that option-clicking the dock unminiaturize windows. hides and unhides, but that's different. as i state above, you can ctrl-click or right click on the dock icon and unminiaturize windows one-by-one. but that's less efficient and again goes back to the main problem: up and down across the screen to get back where you started.) those who don't work in dozens of applications at once may not see the issue here. but those who do will know what i'm talking about.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: snit on Dec 03, '09 11:23:53PM

If you have the windows minimize to the Dock you can option+click to expand them all. If you have them minimize to the icon, as you can with Snow Leopard, you can click and hold on the dock icon where you will see the Exposé minimized windows... and then option+click on any one of those to expand all.

I am not saying that a keyboard way of doing this is not of value, just noting the functionality to un-minimize all is already built in - in ways you said you did not know. Still, the menu methods you show allow someone to do this without using the dock or mouse at all... and that is no doubt a benefit to some.

Edited on Dec 03, '09 11:25:24PM by snit



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: avramd on Jan 11, '10 03:29:13PM

Hello,

So I hope I don't sound like I'm being contrary again since you've had to defend yourself so much already here. But in terms of excessive mouse movements to unminimize all windows, I'm not seeing it.

Just do F10, any arrow key, then opt-return. Three keystrokes, no mouse movements.

Since all the windows are minimized, it doesn't matter which arrow key you hit b/c any window you highlight will be a minimized one, and thus opt-return on it will restore them all.

Is there a scenario this doesn't cover that still requires excessive mouse movements?



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Jan 13, '10 05:57:24AM

two hands and both on keyboard, or one hand in uncomfortable, contorted positions, with a several-step sequence. nice alternate if both hands already on keyboard, but i prefer attaching this script to a trackball chord -- one hand, no keyboard, two clicks.

as mentioned i may do this several times a minute depending, so it makes a big difference. but whatever works for you.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: iRideSnow on Dec 03, '09 03:29:13PM

The hint says, "and you can double-click on a window title bar to do this", no doubt I'm missing something obvious, but how does one enable this?



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Dec 03, '09 03:52:20PM

that's actually rather stupidly in the appearance pref pane. and for clarity's sake, the option to minimize to application icon in dock is in the dock pref pane. (and Apple can't keep its terms straight -- in the GUI it's called minimize, but technically minimize is what happens when you click the zoom button on a window; shrinking it to the dock is called miniaturize the cocoa terms.)



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: iRideSnow on Dec 03, '09 04:30:00PM

Ahhh! Got it. Thanks.



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: zo219 on Dec 08, '09 05:45:17PM

But I want those little windows on the desktop. That was handiest of all.

Make me a script? Thanks!



[ Reply to This | # ]
Minimize/unminize all windows in the active application
Authored by: loren_ryter on Jan 13, '10 05:59:44AM

yeah, agreed. send apple os x feedback about how if they're going to kill the unsanity-type haxies, at least implement windowshade in the os.



[ Reply to This | # ]