Here's some example code to show you how to find and kill a window based on what its caption is displaying
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
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lparam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc1(ByVal hwnd As Long, ByVal lparam As Long) As Boolean
Dim ssave As String, ret As Long
ret = GetWindowTextLength(hwnd)
ssave = Space(ret)
GetWindowText hwnd, ssave, ret + 1
If ssave = "Your window caption goes here" Then
x = PostMessage(hwnd, &H12, 0, 0)
EnumWindowsProc1 = False
Else
EnumWindowsProc1 = True
End If
End Function
'
' Call the above function like this
'
Sub killwin1()
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.