Compartir a través de


CommandWindow.SendInput (Método)

Envía una línea de entrada de texto a la ventana Comando que se procesa como si se escribiera.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

'Declaración
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
)

Parámetros

  • Command
    Tipo: String

    Obligatorio. La cadena de comandos que se envía a la ventana Comando.

  • Execute
    Tipo: Boolean

    Obligatorio. True significa agregar un carácter de nueva línea y ejecutar la línea de entrada; False significa no ejecutar la línea de comandos.

Comentarios

Si el valor de Execute es true, SendInput ejecuta automáticamente el comando. De lo contrario, deberá presionar ENTRAR en la ventana Comando para ejecutarlo. Se puede construir una línea de comandos llamando reiteradamente a este método. Se puede ejecutar después estableciendo Execute en true en la última llamada.

Puede utilizar SendInput para acumular varias líneas de entrada y ejecutarlas siempre que lo desee. Esto difiere del método ExecuteCommand, que ejecuta las instrucciones inmediatamente después de proporcionar la cadena de entrada. SendInput es útil si desea crear líneas de comandos complejas escribiendo manualmente aspectos distintos de la línea de comandos. Además, cuando utilice SendInput podrá ver todos los resultados generados por el comando. Cuando utilice ExecuteCommand no verá ningún resultado y deberá crear una línea de comandos completa en la línea de entrada.

Ejemplos

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();
}

Seguridad de .NET Framework

Vea también

Referencia

CommandWindow Interfaz

EnvDTE (Espacio de nombres)