codice:
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As EnumWindowsProcDelegate, ByVal lParam As Integer) As Integer
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Integer) As Integer
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Integer
Delegate Function EnumWindowsProcDelegate(ByVal hwnd As IntPtr, ByVal lparam As Integer) As Boolean
Public Declare Function DestroyWindow Lib "user32" (ByVal HWND As Integer) As Long
Public numHWD As Long
Public Sub ChiudiFinestrelle()
Dim prova33 As Boolean
numHWD = 0
prova33 = EnumWindows(AddressOf EnumWindowsProc, &H0)
If numHWD > 0 Then Call DestroyWindow(numHWD)
End Sub
Public Function EnumWindowsProc(ByVal HWND As Integer, ByVal lParam As Integer) As Boolean
Dim sSaVe As String, RET As Integer
RET = GetWindowTextLength(HWND)
sSaVe = Space(RET)
GetWindowText(HWND, sSaVe, RET + 1)
If sSaVe.Trim <> "" Then
If InStr(1, LCase(sSaVe), "avviso di protezione", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "errore nello script", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "download del file", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "windows internet explorer", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "connetti a", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "windows media player", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "errore pagina web", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "ambiente di sviluppo", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "messaggio dalla pagina", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "prompt utente explorer", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "aviso de segurança", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "erro de página da web", vbTextCompare) > 0 Then numHWD = HWND
If InStr(1, LCase(sSaVe), "erro de script", vbTextCompare) > 0 Then numHWD = HWND
End If
EnumWindowsProc = True 'continua enumerazione
End Function
Inoltre, avevo trovato anche questo link, però non l'ho provato: