Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CommandWindow.SendInput Method

Sends a line of input to the Command window that is processed as if you typed it.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

void SendInput(
	string Command,
	bool Execute
)

Parameters

Command
Type: System.String

Required. The command string to send to the Command window.

Execute
Type: System.Boolean

Required. True means, add a newline character and execute the line of input, False means, do not execute the command line.

If the value of Execute is true, SendInput automatically runs the command. Otherwise, you must press ENTER in the Command window to run it. You can construct a command line by repeatedly calling this method. You can then execute it by setting Execute to true on the final call.

You can use SendInput to accumulate multiple lines of input and then execute them whenever you want. This differs from the ExecuteCommand method, which executes instructions immediately after you provide the input string. SendInput is useful if you want to create complex command lines by manually entering distinct aspects of the command line. In addition, when you use SendInput, you can view any output generated by the command. When you use ExecuteCommand, you do not see any output, and you must construct a complete command line in your line of input.

void CommandWinExample(_DTE dte) 
{
    // Get a reference to the Command window.
    Window win =    
    dte.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow);
    CommandWindow CW = (CommandWindow)win.Object;

    // Input a command into the Command window and execute it.
    CW.SendInput("nav http://www.microsoft.com", true);

    // Insert some information text into the Command window.
    CW.OutputString("This URL takes you to the main Microsoft 
    website.");

    // Clear the contents of the Command window.
    MessageBox.Show("Clearing the Command window...");
    CW.Clear();
}

Show:
© 2015 Microsoft