1

On Mac OS X (10.6.4) is there a keyboard shortcut to close all other windows except the one with focus?

2 Answers 2

4

Not that I know of.

You can however hide all other applications with Option+Command+H.

2
  • Does ⌥⌘H work differently on 10.6? On earlier releases it only hides other applications (if the current application has multiple windows open, they will all remain visible). Jun 20, 2010 at 20:36
  • @Chris: You are correct, all other applications.
    – Josh K
    Jun 20, 2010 at 22:41
3

You can create an applescript to close all but the frontmost window of the current application. In snow leopard, you can put it in an automator service and give it a keyboard shortcut. Alternatively, you can use Fastscripts to give it a shortcut.

Edit: I've added hiding other applications to the applescript. Edit #2: OK, after testing I found the repeat while window 2 exists actually didn't stop looping, causing nasty autoclose behaviour when opening new windows. The new code should be more robust.

with timeout of 2 seconds
  try
    tell application "System Events"
        set app_name to name of the first process whose frontmost is true
        set visible of (every process) to false -- hide everything
    end tell

    tell application app_name
        activate -- show frontmost application
        repeat with aWindow in (get every window)
            if index of aWindow > 1 then close aWindow
        end repeat
    end tell
  on error error_message number error_number
    display alert ("Something went wrong:") ¬
        message error_message ¬
        & (" Error number ") & error_number & "."
  end try
end timeout

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .