다음을 통해 공유


방법: 애플리케이션 시작 및 키 입력 보내기(Visual Basic)

이 예제에서는 Shell 메서드를 사용하여 메모장 애플리케이션을 시작한 다음, My.Computer.Keyboard.SendKeys 메서드를 통해 키 입력을 보내 문장을 출력합니다.

예시

Dim ProcID As Integer
' Start the Notepad application, and store the process id.
ProcID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus)
' Activate the Notepad application.
AppActivate(ProcID)
' Send the keystrokes to the Notepad application.
My.Computer.Keyboard.SendKeys("I ", True)
My.Computer.Keyboard.SendKeys("♥", True)
My.Computer.Keyboard.SendKeys(" Visual Basic!", True)
' The sentence I ♥ Visual Basic! is printed on Notepad.

강력한 프로그래밍

요청된 프로세스 식별자를 가진 애플리케이션을 찾을 수 없는 경우 ArgumentException 예외가 발생합니다.

.NET Framework 보안

Shell 함수에 대한 호출은 완전 신뢰가 필요합니다(SecurityException 클래스).

참고 항목