全局代码
<DllImport("user32.dll", EntryPoint := "FindWindow", SetLastError := True)> _
Public Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint := "FindWindowEx", SetLastError := True)> _
Public Function FindWindowEx(hwndParent As IntPtr, hwndChildAfter As UInteger, lpszClass As String, lpszWindow As String) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint := "SendMessage", SetLastError := True, CharSet := CharSet.Auto)> _
Public Function SendMessage(hwnd As IntPtr, wMsg As UInteger, wParam As IntPtr, lParam As Integer) As Integer
End Function
Public Sub CloseWin(winTitle As String, buttonTitle As String)
Dim hwnd As IntPtr = FindWindow(Nothing, winTitle)
If hwnd <> IntPtr.Zero Then
'Dim hwndText As IntPtr = FindWindowEx(hwnd, 0, Nothing, "请设置浏览器的安全级别.启用activeX脚本!")
'If hwndText <> IntPtr.Zero Then
Dim hwndSure As IntPtr = FindWindowEx(hwnd, 0, "Button", buttonTitle)
If hwnd <> IntPtr.Zero Then
SendMessage(hwndSure, &Hf5, 0, 0)
'按她
End If
'End If
End If
End Sub
调用代码,你可以做一个定时器,定时执行
CloseWin("提示", "否(&N)")