Share via


CommandWindow.SendInput 메서드

직접 입력한 것처럼 처리되는 입력 줄을 명령 창에 보냅니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
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
)

매개 변수

  • Command
    형식: String

    필수입니다. 명령 창에 보낼 명령 문자열입니다.

  • Execute
    형식: Boolean

    필수입니다. True로 설정하면 줄 바꿈 문자가 추가된 후 입력 줄이 실행되고, False로 설정하면 명령줄이 실행되지 않습니다.

설명

Execute의 값이 true이면 SendInput에서 자동으로 명령을 실행합니다. 그렇지 않으면 명령 창에서 Enter 키를 눌러 명령을 실행해야 합니다. 이 메서드를 반복해서 호출하여 명령줄을 만들 수 있습니다. 그런 다음 최종 호출에서 Execute를 true로 설정하여 이 명령줄을 실행할 수 있습니다.

SendInput 메서드를 사용하여 여러 입력 줄을 누적시킨 다음 필요할 때마다 실행할 수 있습니다. 이 메서드는 사용자가 입력 문자열을 제공하면 바로 명령을 실행하는 ExecuteCommand 메서드와 다릅니다. SendInput은 명령줄의 필요한 요소를 직접 입력하여 복잡한 명령줄을 만들 때 유용합니다. 또한 SendInput 메서드를 사용하면 명령을 통해 생성된 출력을 볼 수 있습니다. ExecuteCommand 메서드를 사용하면 출력이 표시되지 않으므로 입력 줄에 전체 명령줄을 구성해야 합니다.

예제

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 보안

참고 항목

참조

CommandWindow 인터페이스

EnvDTE 네임스페이스