Wednesday, July 18, 2007

Close All Annoying Windows -- I just want a monitor full of code!

I find it annoying to have to constantly be closing those windows that appear at the bottom of the screen whenever you do a "Find in files", or the error list window. Mapping this macro to a hot-key is a handy shortcut to avoid having to close these all up by clicking on the "X".

Sub CloseBottomWindows()
DTE.Windows.Item(Constants.vsWindowKindOutput).Close()
DTE.Windows.Item(Constants.vsWindowKindFindResults1).Close()
DTE.Windows.Item(Constants.vsWindowKindTaskList).Close()
End Sub


Some of the windows may not have a "vsWindowKind" constant. In that case, you can close them by finding them by the window title.

' Hide windows that match certain titles
Sub HideOtherBottomWindows()
Dim window As Window
For Each window In DTE.Windows
'MsgBox(window.Caption)
If (window.Caption.Equals("File Finder")) Then
window.Close()
End If
If (window.Caption.Contains("Code Definition Window")) Then
window.Close()
End If
If (window.Caption.Contains("Error List")) Then
window.Close()
End If
If (window.Caption.Equals("VA Find References Results")) Then
window.Close()
End If
Next
End Sub

No comments: