Something like this:
VB Code:
'Module code: Dim Wnd As Long Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, _ ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As _ Long) As Long Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, _ ByVal nIDEvent As Long) As Long Public Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, ByVal _ lpWindowName As String) As Long Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) Wnd = FindWindow("ProgramClass", "ProgramTitle") If Wnd = 0 Then Shell "Program.exe", 1 End Sub Sub StartTimer(ByVal lInterval) SetTimer Form1.hwnd, 100, lInterval, AddressOf TimerProc End Sub Sub StopTimer() KillTimer Form1.hwnd, 100 End Sub 'Form Code: Private Sub Form_Activate() StartTimer 500 End Sub Private Sub Form_Unload(Cancel As Integer) StopTimer End Sub




Reply With Quote