'How to get text from property class : internet explorer_server to richtextbox
is it possible to get text from chat application, I use spy++ and the property class is internet explorer_server and I want to display it in richtextbox, i made it on vbnet I've googled but can't find anything, can anyone help?
thank you
thats code i have trying but not work.
Imports mshtml Imports System.Text Imports System.Runtime.InteropServices
Public Class Form1
Inherits Form
<DllImport("user32.dll", EntryPoint:="GetClassNameA")>
Public Shared Function GetClassName(ByVal hwnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
End Function
Public Delegate Function EnumProc(ByVal hWnd As IntPtr, ByRef lParam As IntPtr) As Integer
<DllImport("user32.dll")>
Public Shared Function EnumChildWindows(ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumProc, ByRef lParam As IntPtr) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="RegisterWindowMessageA")>
Public Shared Function RegisterWindowMessage(ByVal lpString As String) As Integer
End Function
<DllImport("user32.dll", EntryPoint:="SendMessageTimeoutA")>
Public Shared Function SendMessageTimeout(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer, ByVal fuFlags As Integer, ByVal uTimeout As Integer, <Out> ByRef lpdwResult As Integer) As Integer
End Function
<DllImport("OLEACC.dll")>
Public Shared Function ObjectFromLresult(ByVal lResult As Integer, ByRef riid As Guid, ByVal wParam As Integer, ByRef ppvObject As IHTMLDocument2) As Integer
End Function
Public Const SMTO_ABORTIFHUNG As Integer = &H2
Public IID_IHTMLDocument As New Guid("70391899-3fc0-4b82-981a-ac81bc29b40e")
Public document As IHTMLDocument2
Private Function DocumentFromDOM() As IHTMLDocument2
Dim processes As Process() = Process.GetProcessesByName("Camfrog Video Chat.exe")
If processes.Length > 0 Then
Dim hWnd As IntPtr = processes(0).MainWindowHandle
Dim lngMsg As Integer = 0
Dim lRes As Integer
Dim proc As New EnumProc(AddressOf EnumWindows)
EnumChildWindows(hWnd, proc, hWnd)
If hWnd.Equals(IntPtr.Zero) Then
Return document
End If
lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT")
If lngMsg <> 0 Then
SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes)
If Not (lRes = 0) Then
Dim hr As Integer = ObjectFromLresult(lRes, IID_IHTMLDocument, 0, document)
If (document Is Nothing) Then
MessageBox.Show("No IHTMLDocument Found!", "Warning")
End If
End If
End If
Return document
End If
Return document
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
document = DocumentFromDOM()
If Not (document Is Nothing) Then
RichTextBox2.Text = document.url
End If
End Sub
Private Function EnumWindows(ByVal hWnd As IntPtr, ByRef lParam As IntPtr) As Integer
Dim retVal As Integer = 1
Dim classname As New StringBuilder(128)
GetClassName(hWnd, classname, classname.Capacity)
If String.Compare(classname.ToString(), "Internet Explorer_Server") = 0 Then
lParam = hWnd
retVal = 0
End If
Return retVal
End Function
End Class
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
