监视IE窗口内容
API练习,不知道是不是应该发表为普通帖子程序代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Sub Command1_Click() Dim IEtext As String IEtext = Space(300) Handle = FindWindow("IEFrame", vbNullString) If Handle <> 0 Then GetWindowText Handle, IEtext, 299 If InStr(1, IEtext, "zaroty") Then PostMessage Handle, &H10, 0, 0 ' 红色部分为识别的关键字 End Sub