Something like this:


VB Code:
  1. 'Module code:
  2.  
  3. Dim Wnd As Long
  4.  
  5. Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, _
  6. ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As _
  7. Long) As Long
  8.  
  9. Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, _
  10. ByVal nIDEvent As Long) As Long
  11.  
  12. Public Declare Function FindWindow Lib "user32" _
  13. Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
  14. lpWindowName As String) As Long
  15.  
  16. Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
  17.     Wnd = FindWindow("ProgramClass", "ProgramTitle")
  18.     If Wnd = 0 Then Shell "Program.exe", 1
  19. End Sub
  20.  
  21. Sub StartTimer(ByVal lInterval)
  22.     SetTimer Form1.hwnd, 100, lInterval, AddressOf TimerProc
  23. End Sub
  24.  
  25. Sub StopTimer()
  26.     KillTimer Form1.hwnd, 100
  27. End Sub
  28.  
  29.  
  30. 'Form Code:
  31.  
  32.  
  33. Private Sub Form_Activate()
  34.     StartTimer 500
  35. End Sub
  36.  
  37. Private Sub Form_Unload(Cancel As Integer)
  38.     StopTimer
  39. End Sub