CommandWindow.SendInput, méthode

Envoie une chaîne d'entrée vers la fenêtre Commande. Cette chaîne est alors traitée comme toute chaîne que vous auriez vous-même saisie dans la fenêtre.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
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
)

Paramètres

  • Command
    Type : System.String
    Obligatoire.Chaîne de commande à envoyer dans la fenêtre Commande.
  • Execute
    Type : System.Boolean
    Obligatoire.True signifie, ajoutez un caractère de saut de ligne et exécutez la ligne d'entrée, False signifie, n'exécutez pas la ligne de commande.

Notes

Si la valeur de Execute est true, SendInput exécute automatiquement la commande. Sinon, vous devez appuyer sur la touche ENTRÉE dans la fenêtre Commande pour l'exécuter. Vous pouvez construire une ligne de commande en appelant cette méthode à plusieurs reprises. Vous pouvez ensuite l'exécuter en affectant la valeur true à Execute pour le dernier appel.

SendInput vous permet de regrouper plusieurs lignes d'entrée, puis de les exécuter ultérieurement, à votre convenance. Cela diffère de la méthode ExecuteCommand qui exécute immédiatement les instructions après avoir fourni la chaîne d'entrée. SendInput est utile si vous souhaitez créer des lignes de commande complexes en entrant manuellement les aspects distincts de la ligne de commande. De plus, lorsque vous utilisez SendInput, vous êtes en mesure de visualiser toute sortie générée par la commande. Lorsque vous utilisez ExecuteCommand, aucune sortie n'est visible et vous devez générer une ligne de commande complète dans votre chaîne d'entrée.

Exemples

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

Sécurité .NET Framework

Voir aussi

Référence

CommandWindow Interface

EnvDTE, espace de noms