怎么有VB编程实现获取IE浏览器弹出窗口中的内容

2024-11-17 07:39:17
推荐回答(3个)
回答(1):

能的 Dim dWinFolder As New ShellWindows
Dim WithEvents eventIE As WebBrowser_V1

Private Sub Command1_Click()
Dim objIE As Object

For Each objIE In dWinFolder
If objIE.LocationURL = List1.List(List1.ListIndex) Then
Set eventIE = objIE
Command1.Enabled = False
List1.Enabled = False
Text1.Text = ""
Exit For
End If
Next
End Sub

Private Sub eventIE_NavigateComplete(ByVal URL As String)
Text1.Text = Text1.Text + Chr(13) + Chr(10) + URL
End Sub

在运行前。点击菜单 Projects ¦ References 项,在Available References 列表中选择Microsoft Internet Controls项将Internet对象引用介入到工程中

Private Sub Form_Load()
Dim objIE As Object

For Each objIE In dWinFolder
If InStr(1, objIE.FullName, "IEXPLORE.EXE", vbTextCompare) <> 0 Then
List1.AddItem objIE.LocationURL
End If
Next
Command1.Caption = "正文"
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set dWinFolder = Nothing
End Sub

Private Sub List1_Click()
Dim objDoc As Object
Dim objIE As Object

For Each objIE In dWinFolder
If objIE.LocationURL = List1.List(List1.ListIndex) Then
Set objDoc = objIE.Document

For i = 1 To objDoc.All.length - 1
If objDoc.All(i).tagname = "BODY" Then
Text1.Text = objDoc.All(i).innerText
End If
Next
Exit For
End If
Next
End Sub

回答(2):

通过API函数获取窗口句柄。

回答(3):

VB办不到吧