Close all tool windows in Visual Studio?

2020-02-25 08:35发布

问题:

I've started to pull out my tool windows in VS2010. I like the way it works, I put tool windows on one monitor, and my code on the other.

However, my only gripe is occasionally I want to quickly close all the tool windows, and I'd love a way to close them all in one fell swoop.

I know about Shift-Esc to close an individual window, but is there a way to close ALL tool windows at once?

A VS2010 specific answer is fine, but anything that would work would be swell.

Thanks!

回答1:

Ok, thanks to this blog I was able to cobble together a working solution. I'll recap it here in case that link ever dies, but all credit goes to The Boolean Frog (aka Pascal).

Create a macro in Visual Studio 2010 (Under Tools -> Macros -> Macros IDE...) and put this code inside a public module:

Public Sub CloseAllToolWindows()
    Dim items As EnvDTE.Windows = DTE.Windows
    Dim item As Window

    For Each item In items
        If item.Kind.Equals("Tool") And item.Visible Then
            item.Close()
        End If
    Next
End Sub

Then head to Tools -> Options -> Enivornment -> Keyboard, inside the dialog there, under the Show commands containing: box, search for Macros. Your newly created macro is right there, assign it a keyboard shortcut, and Bob's your uncle you can close all Tool Windows :)

I personally used the code Ctrl-W, C for, umm, "Window, Close" but you can use whatever you'd like :)



回答2:

You can assign a key to Window.AutoHideAll in vs2010 under Tools, Options Environment, Keyboard or use "Fullscreen" but these just hide the windows, not close them.



回答3:

As far as I know, there is no chance to close all tool windows :-/ What I do is to auto hide all windows, maybe this works for you too?!

In Visual Studio go to "Window" -> and click on "Auto Hide"