views:

428

answers:

2

Hi folks,

is it possible to have a way to clear the Visual Studio OUTPUT window, programatically? For example, the SysInternal's debugger app called DebugView has the specific command called DBGVIEWCLEAR .. which clears the log window.

Please don't say: right-click, clear window .. with the mouse. I know that, but that's not what i'm after.

cheers :)

+1  A: 

What about Console.Clear()?

The Chairman
That only works in a console app :( http://stackoverflow.com/questions/766173/how-to-clear-the-console-in-c-net
Pure.Krome
+2  A: 

For VS 2008 try this code

EnvDTE80.DTE2 ide = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0");
ide.ExecuteCommand("Edit.ClearOutputWindow", "");
System.Runtime.InteropServices.Marshal.ReleaseComObject(ide);

"VisualStudio.DTE.9.0" will change from VS version to version.

astander
what assembly / namespace to i need to reference for EnvDTE80? (btw. i'm on VS2010).
Pure.Krome
Added EnvDTE.dll and EnvDTE80.dll.
astander
So this means this code is VERY Visual Studio version dependent? (And it doesn't work in VS2010 RC ... even when i change to `GetActiveObject("VisualStudio.DTE.10.0");` Compiles and runs, but doesn't clear that window.
Pure.Krome
I Lie. it does clear the window. No idea why it didn't the first time around.
Pure.Krome