Internet Explorer_Server class window
Anyone know how to pull text out of this kind of control? It is an Internet Explorer_Server class control inside of a messenger window, namely Yahoo. The chat room text. I want to pull this data out and analyze it. I cant seem to even pull the handle out through code (but i can see it through Spy++). The parent is YHTMLContainer class, and the YHTMLContainer is the child to the IMClass class.
The following code executes correctly:
VB Code:
hWndTmp = FindWindow("IMClass", "*Replaced with WindowTitle*")
hWndChild = FindWindowEx(hWndTmp, 0, "YHTMLContainer", vbNullString)
Kinda confused next.. The Internet Explorer_Server is the child of a child, per se.. the child of YHTMLContainer.... how would I get the handle.. i tried doing a FindWindow on just the class Internet Explorer_Server but kept returning nothing. Also, doing a FindWindowEx on Internet Explorer_Server also returned nothing.
All this and I still have to figure out how to get the text in the control to my application... :ehh:
Re: Internet Explorer_Server class window
Do FindWindowEx() on hWndChild. Also, you can just pass vbNullString instead of the window title, unless you specifically need to find that window.
so
VB Code:
hWndTmp = FindWindow("IMClass", "*Replaced with WindowTitle*")
hWndChild = FindWindowEx(hWndTmp, 0, "YHTMLContainer", vbNullString)
hWndIEServer = FindWindowEx(hWndChild, 0&, "Class name of IE server", vbNullString)
Re: Internet Explorer_Server class window
Oh and, to get the text, try
VB Code:
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
lLen = SendMessage(hWndIEServer, WM_GETTEXTLENGTH, 0, ByVal 0&)
SendMessage hWndIEServer, WM_GETTEXT, lLen + 1, sText
Re: Internet Explorer_Server class window
Hmmm.. couldve sworn I tried that 10 times already, but copied your third line into mine for the hwndIEServer and it worked lol ... thx :) gonna work on the text part now...
Re: Internet Explorer_Server class window
The code to get the text doesnt work.. i returns a zero value. The code I have so far is below, all the handles pull nonzerovalues. The SendMessage statements return 0.
VB Code:
hWndTmp = FindWindow("IMClass", "SymbolType")
hWndChild = FindWindowEx(hWndTmp, 0, "YHTMLContainer", vbNullString)
hWndIEServer = FindWindowEx(hWndChild, 0, "Internet Explorer_Server", vbNullString)
Dim lLen As Long
Dim IElen As Long
Dim sText As String
lLen = SendMessage(hWndIEServer, WM_GETTEXTLENGTH, 0, IElen)
SendMessage(hWndIEServer, WM_GETTEXT, lLen + 1, sText)
Re: Internet Explorer_Server class window
Im guessing the code won't work because it is some sort of HTML object. Anyone know how to pull text from the Internet Explorer_Server class window? The same class is used as the main window in Internet Explorer, so surely someone out there has done it.
Re: Internet Explorer_Server class window
I now am pulling the HTML Object out of the window, but I am still getting a blank document. Here is some of the code :
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objDoc As IHTMLDocument
hWndTmp = FindWindow("IMClass", "*window title*")
hWndChild = FindWindowEx(hWndTmp, 0, "YHTMLContainer", vbNullString)
hWndIEServer = FindWindowEx(hWndChild, 0, "Internet Explorer_Server", vbNullString)
MsgBox(hWndIEServer)
If hWndIEServer > 0 Then
objDoc = WindowDOM(hWndIEServer)
If Not (objDoc Is Nothing) Then
MsgBox(objDoc.body.innerText)
End If
End If
End Sub
The Associated Functions and structures are below :
VB Code:
Declare Function ObjectFromLresult Lib "oleacc.dll" ( _
ByVal lResult As Int32, _
ByVal riid As UUID, _
ByVal wParam As Int32, _
ByVal ppvObject As Object) As Int32
Declare Function RegisterWindowMessage Lib "user32.dll" Alias "RegisterWindowMessageA" ( _
ByVal lpString As String) As Int32
Declare Function SendMessageTimeout Lib "user32.dll" Alias "SendMessageTimeoutA" ( _
ByVal hWnd As Int32, _
ByVal Msg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32, _
ByVal fuFlags As Int32, _
ByVal uTimeout As Int32, _
ByVal lpdwResult As Int32) As Int32
Public Structure UUID
Public Data1 As Long
Public Data2 As Integer
Public Data3 As Integer
Public Data4() As Byte
End Structure
Public Function WindowDOM(ByVal hWnd As Int32) As IHTMLDocument
Dim typUUID As UUID, lngRes As Int32, lngMsg As Int32
lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT")
'MsgBox(lngMsg.ToString & " lngmessage")
If lngMsg <> 0 Then
Call SendMessageTimeout(hWndIEServer, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lngRes)
MsgBox(lngRes.ToString)
If lngRes <> 0 Then
With typUUID
.Data1 = &H626FC520
.Data2 = &HA41E
.Data3 = &H11CF
.Data4(0) = &HA7
.Data4(1) = &H31
.Data4(2) = &H0
.Data4(3) = &HA0
.Data4(4) = &HC9
.Data4(5) = &H8
.Data4(6) = &H26
.Data4(7) = &H37
End With
Call ObjectFromLresult(lngRes, typUUID, 0, WindowDOM)
End If
End If
End Function
The code all runs without errors, however the "objDoc = WindowDOM(hWndIEServer)" posted on the button click is a blank document, because the If statement isnt ran.
The SendMessageTimeout function call in the WindowDom function brings back a message of 0, which is where i think the holdup is. I can feel im getting real close... anyone know of something i can try??
Re: Internet Explorer_Server class window
Hey,
Did you ever get this going? I'm currently working on the same issue. Let me know if you found the solution. - Thanks Dennis
Re: Internet Explorer_Server class window
I sure did WingMan... my code was a little messy, but I did find some code on the net that utilizes an IEDom class, to get the http object. Have it in a project that returns the innertext of the document that is currently inside the Internet Explorer window.... gimme a few minutes and I'll post the code....
Rather... do you want the code to get the text out of Internet Explorer?? or in regards to Yahoo Instant Messenger, which also uses the Internet Explorer_Class window??
2 Attachment(s)
Re: Internet Explorer_Server class window
Here's the code where you can get the information into a string from the class window hwnd.. its in an IEdom class and in a win32 functions class... to get the html into a string, you just call the following:
VB Code:
'hwndTmpGetIE is the handle to the Internet Explorer_Class window....
Dim i As IHTMLDocument = ieDom.IEDOMFromhWnd(hwndTmpGetIE)
strHTML = Strings.LCase(i.documentElement.innertext.ToString)
And the two classes are attached below (the win32 functions class has more declarations that is actually used, its just a common class I use that I put my API functions in..)
**Note been a while since I used this code, and it might be a little messy because I was just first beginning when I wrote it...
Re: Internet Explorer_Server class window
check if this page helps you.
Edit: Great ! You have solved it. :thumb:
Re: Internet Explorer_Server class window
:rolleyes: redi can't run success,get nothing,have all code?
Re: Internet Explorer_Server class window
i am use vb6,i think that can get vb6's all code?
Re: Internet Explorer_Server class window
The code posted was .NET code, if that helps explain a little as to why it won't work in VB6... you would have to use the VB6 declarations...
Re: Internet Explorer_Server class window
Can you change that code to C#.Net?