vb如何通过ie窗口句柄获取窗口内容 10
展开全部
1、方法
通过窗口句柄,获取webbrowser控件HTML内容
2、代码
Dim obj As HTMLDocumentClass = DirectCast(Win32API.ObjectFromLresult(lRes, GetType(IHTMLDocument).GUID, IntPtr.Zero), HTMLDocumentClass)
Return obj
End Function
Public Shared Function GetIEWindowDocument(ByVal windowName As String) As HTMLDocumentClass
Dim lRes As New UIntPtr()
Dim parentHWnd As IntPtr = Win32API.FindWindow(Nothing, windowName)
MessageBox.Show(parentHWnd.ToString())
Dim editHWnd As IntPtr = Win32API.FindWindowEx(parentHWnd, IntPtr.Zero, "SplitterBar", "")
'需要查找的子窗口的类名,也就是输入框
MessageBox.Show(editHWnd.ToString())
Dim editHWnd1 As IntPtr = Win32API.FindWindowEx(editHWnd, IntPtr.Zero, "StandardWindow", "")
'需要查找的子窗口的类名,也就是输入框
MessageBox.Show(editHWnd1.ToString())
Dim editHWnd2 As IntPtr = Win32API.FindWindowEx(editHWnd1, IntPtr.Zero, "SimpleBrowser", "")
'需要查找的子窗口的类名,也就是输入框
Dim editHWnd3 As IntPtr = Win32API.FindWindowEx(editHWnd2, IntPtr.Zero, "Shell Embedding", "")
'需要查找的子窗口的类名,也就是输入框
Dim editHWnd4 As IntPtr = Win32API.FindWindowEx(editHWnd3, IntPtr.Zero, "Shell DocObject View", "")
'需要查找的子窗口的类名,也就是输入框
MessageBox.Show("Shell DocObject View" & editHWnd2.ToString())
Dim editHWnd5 As IntPtr = Win32API.FindWindowEx(editHWnd4, IntPtr.Zero, "Internet Explorer_Server", "")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询