MSDN Library

How to: Control the Command Window

Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions. For more information about upgrading, see FAQ: Converting Add-ins to VSPackage Extensions.

The CommandWindow object represents the Command window in the Visual Studio automation model. You can use the CommandWindow object to:

  • Insert a command into the Command window and, optionally, execute it by using the SendInput method.

  • Insert informational text into the Command window by using the OutputString method.

  • Clear all text from the Command window by using the Clear method.

In addition to controlling the contents of the Command window, you can also control its characteristics, such as width and height. For more information, see How to: Change Window Characteristics.

Note Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. These procedures were developed with the General Development Settings active. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

This example demonstrates how to reference and use the various members of the Command window automation model. For more information about how to run the example, see How to: Compile and Run the Automation Object Model Code Examples.

public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.

public void CommandWinExample(DTE2 dte)
        // Get a reference to the Command window.
        CommandWindow CW = dte.ToolWindows.CommandWindow;

        // Insert informative text into the Command window.
        CW.OutputString("This takes you to the Microsoft Web site.");

        // Add a command to the Command window and execute it.
        CW.SendInput("nav", true);

        // Clear the contents of the Command window.
          "Clearing the Command window...");
    catch (Exception ex)
© 2015 Microsoft