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)
Syntax
'Declaration
Sub SendInput ( _
Command As String, _
Execute As Boolean _
)
void SendInput(
string Command,
bool Execute
)
void SendInput(
String^ Command,
bool Execute
)
abstract SendInput :
Command:string *
Execute:bool -> unit
function SendInput(
Command : String,
Execute : boolean
)
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.
Remarks
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.
Examples
Sub CommandWinExample(ByVal dte As DTE)
' Get a reference to the Command window.
Dim win As Window = _
DTE.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow)
Dim CW As CommandWindow = win.Object
' Input a command into the Command window and execute it.
CW.SendInput("nav https://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.
MsgBox("Clearing the Command window...")
CW.Clear()
End Sub
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 https://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();
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.