Is their anyway to check to see if something for example Yahoo pager was running, and tell my computer to shut it down whenever it was running?
Printable View
Is their anyway to check to see if something for example Yahoo pager was running, and tell my computer to shut it down whenever it was running?
Use the FindWindow API.
Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Const WM_DESTROY = &H2
Private Sub Command1_Click()
'Get the hWnd of the App
hParent = FindWindow(vbNullString, "MyAppTitle")
'If it's found then close it
If hParent <> 0 Then
SendMessage hParent, WM_CLOSE, 0, 0
SendMessage hParent, WM_CLOSE, 0, 0
End If
End Sub
Thanks! I will test it when i get home from work but thank you so much!
If you know the exe, than you can do it this way: App List and Kill and you can add this code to search for it:
Code:'Either:
For i = 0 to List1.ListCount - 1
If List1.List(i) = "C:\Program Files\Yahoo\Yahoo Pager.exe" Then Msgbox "Yahoo Page is open!":Exit Sub' change it to whatever the exe's name is.
Next i
'Or:
For i = 0 to List1.ListCount - 1
List1.ListIndex = List1.ListIndex + 1
If List1 = "C:\Program Files\Yahoo\Yahoo Pager.exe" Then Msgbox "Yahoo Pager is open!":Exit Sub
Next i