Use of AppActivate with VB.NET
Posted on 2004-04-30
The following piece of code in Button5 has been working to enter a much used application every day for the last year.
I initially had problems in gettting the sendkeys to work but found that typing the AppActivate line twice fixed the problem.
I have now added an additional Button6 to my apllication with very little code in it and have not altered the code in Button5 at all.
The problem is that external program gets to the point where the "Open Company" screen is active but my program does not sendkeys (the original problem before I typed the AppActivate line twice) and so it just waits at the correct screen but goes no further.
I cant understand how Button5 does not work anymore given that I have not altered the code for that Button at all.
If anyone can suggest whats wrong or give an alternative solution I'll be very grateful. I am using Windows 2000 Professional and VB.NET
'My Coding follows..
'I have this at the top of my program..
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
'Other code follows here ...
'Routine to open a third party program and enter predifined values into its User Name / Password screen and also enter a predefined date
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim i As Integer
Dim strprodate As String
Dim DUM As String
'start the payroll program
Shell("c:\Payroll Programs\payroll.exe", vbNormalFocus)
' next line to create a pause while the external program starts up
DUM = InputBox("YOU MUST CLICK OK in this little box when Payroll list appears... ", "CLICK OK ON THIS LITTLE BOX WHEN PAYROLL LIST APPEARS", , 200, 50)
' get predefined value from external file
FileOpen(1, "C:\STATUS\STATUS.CUR", OpenMode.Input)
' set focus on the Open Company form... does not work unless statement is written twice... I dont know why...
'send characters to the active form
' these tabs get me to the correct screen
' I always want to start on the third line down so I go up to the top of the form and then down three lines
For i = 1 To 5
For i = 1 To 3
' password is blank so just hit enter