Visual basic is driving me crazy. I'm trying to control an application already open by sending keystrokes. The code is as follows:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim seqc As Process
seqc = New Process()
seqc = Process.Start("C:\seqc\seqc.exe")
System.Threading.Thread.Sleep(1000) ' Wait 1 sec and hit enter on main screen
AppActivate(seqc.Id)
SendKeys.Send("{ENTER}")
System.Threading.Thread.Sleep(1000) ' wait 1 sec, hit tab and hit enter in second screen
SendKeys.Send("{TAB}")
SendKeys.Send("{ENTER}")
End Sub
The problem is that most times it does not work. Increasing the waiting time, does not help either.
It seems that System.Threading.Thread.Sleep is not working properly.
Any ideas?
Thank you very much