Search code examples
visual-studiodebuggingconsoleappender

Can the Visual Studio (debug) Output window be programmatically cleared?


is it possible to have a way to clear the Visual Studio OUTPUT window, programmatically? 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.


Solution

  • 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.