Condividi tramite


Metodo CommandWindow.SendInput

Invia alla finestra di comando una riga di input che viene elaborata come se fosse stata digitata dall'utente.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

'Dichiarazione
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
)

Parametri

  • Command
    Tipo: System.String
    Obbligatorio.La stringa di comando da inviare alla finestra di comando.
  • Execute
    Tipo: System.Boolean
    Obbligatoria.True comporta l'aggiunta di un carattere di nuova riga e l'esecuzione della riga di input, False comporta la mancata esecuzione della riga di comando.

Note

Se il valore di Execute è true, il metodo SendInput esegue automaticamente il comando. In caso contrario è necessario premere INVIO nella finestra di comando per eseguirlo. È possibile creare una riga di comando richiamando più volte questo metodo. È possibile quindi eseguirla impostando Executesu true nella chiamata finale.

È possibile utilizzare il metodo SendInput per riunire più righe di input da eseguire in qualsiasi momento. Questo metodo è diverso dal metodo ExecuteCommand, che esegue le istruzioni subito dopo che l'utente ha fornito la stringa di input. SendInput è utile se si desidera creare righe di comando complesse immettendo manualmente aspetti diversi della riga di comando. Utilizzando SendInput è possibile, inoltre, vedere l'output generato dal comando. Quando si utilizza ExecuteCommand non viene visualizzato alcun output ed è necessario creare una riga di comando completa nella riga di input.

Esempi

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

CommandWindow Interfaccia

Spazio dei nomi EnvDTE