Evo resenja na brzinu:
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_QUIT = &H12
Public StartovanJeExeProgram As Boolean
Private Sub Command1_Click()
End
End Sub
Private Sub Timer1_Timer()
Dim NatpisProzora As String
Dim imeexeprograma As String
NatpisProzora = "Fabricki serijski broj diska"
If Trazi(NatpisProzora) = True Then
Label1.Caption = "Postoji ime prozora " & NatpisProzora & " u Task manageru"
If StartovanJeExeProgram = False Then
Shell "C:\proba\Upozorenje.exe", vbNormalFocus
StartovanJeExeProgram = True
End If
Label2.Caption = "Pokrenut je i program Upozorenje.exe"
Else
Label1.Caption = "Ne postoji prozor " & NatpisProzora & " u Task manageru"
Label2.Caption = ""
End If
End Sub
Public Function Trazi(ImeProzora) As Boolean
Dim sTitle As String
Dim iHwnd As Long
Dim ihTask As Long
Dim iReturn As Long
sTitle = ImeProzora
iHwnd = FindWindow(0&, sTitle)
If iHwnd = 0 Then
Trazi = False
Else
Trazi = True
End If
If StartovanJeExeProgram = True Then
If Trazi = False Then
'Pri zatvaranju prozora "Fabricki serijski broj diska" zatvaranje i prozora Upozorenje!
sTitle = "Upozorenje!"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(iHwnd, WM_QUIT, 0&, 0&)
End If
End If
End Function
rgdrajko