Hi all i got this code that supposed to stop timer1 and timer2 when i get a popup message from an external application that application form failed!
The problem is that when i get such popup the timer never stops automatically and i have to press Command6_Click few times until the timer2 and timer 3 stops!.(i know timer2 and timer 1 didn't stop because the form is getting re submitting over and over and i get that failed message popup again and again...) Could you guys tell me what i am doing wrong ? i want stop the timer1 and timer2 immediately when i get failed popup!Hope you guys help me solve this problem.Thanks
Code:Private Sub Timer1_Timer() Dim hParent As Long Dim hChild As Long 'To find the Parent window Do hParent = FindWindow("#32770", "Welcome to application") DoEvents Loop Until hParent If Not hParent = 0 Then lngStatic = FindWindowEx(hParent, 0&, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) lngStatic = FindWindowEx(hParent, lngStatic, "static", vbNullString) 'If button found then click it. If lngStatic <> 0 Then 'Now we clicked the button ''Call SendMessage(hChild, BM_CLICK, 0, 0) Call SendMessageLong(lngStatic, WM_LBUTTONDOWN, 0&, 0&) Call SendMessageLong(lngStatic, WM_LBUTTONUP, 0&, 0&) End If End If End Sub Private Sub Timer2_Timer() Dim hParent2 As Long 'Do hParent2 = FindWindow("#32770", "Registration Form") ' DoEvents ' Loop Until hParent If Not hParent2 = 0 Then Command2_Click '' is filling the form in external application End If End Sub Private Sub Timer3_Timer() Dim x As Long, x = FindWindow("#32770", "The application form has failed") If Not x = 0 Then Command6_Click ' this function suppose to stop the timers but it doesn't ! 'Timer1.Enabled = False 'Timer2.Enabled = False End If End Sub Private Sub Command6_Click() Timer1.Enabled = False Timer2.Enabled = False End Sub




Reply With Quote