Share via


Nasıl yapılır: Bir uygulamayı başlatma ve tuş vuruşları gönderme (Visual Basic)

Bu örnek, Not Defteri uygulamasını başlatmak için yöntemini kullanır Shell ve ardından My.Computer.Keyboard.SendKeys yöntemini kullanarak tuş vuruşları göndererek bir tümce yazdırır.

Örnek

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.

Sağlam programlama

ArgumentException İstenen işlem tanımlayıcısı olan bir uygulama bulunamazsa bir özel durum oluşur.

.NET Framework Güvenliği

İşlev çağrısı Shell tam güven (SecurityException sınıf) gerektirir.

Ayrıca bkz.