How to: start an application and send it keystrokes (Visual Basic)
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.
An ArgumentException exception is raised if an application with the requested process identifier cannot be found.
.NET Framework Security
The call to the
Shell function requires full trust (SecurityException class).
Submit and view feedback for