Sign in to follow this  
Followers 0
mcollard

Window Text Capture Problem

15 posts in this topic

I'm trying to capture text on a Internet Exploer Server window, in the following class instance : [CLASS:Internet Explorer_Server; INSTANCE:2]

However, when I attempt it, I'm getting a blank back. Can anyone shed some light on this? This Internet Explorer_Server instance is killing me!

I put the dump for Auto Window Info and the code I'm trying to use below:

Thanks in advance,

>>>> Window <<<<

Title: 15 sessions

Class: TriChatFrame

Position: -916, 172

Size: 845, 971

Style: 0x16CF0000

ExStyle: 0x00040100

Handle: 0x000306E8

>>>> Control <<<<

Class: Internet Explorer_Server

Instance: 2

ClassnameNN: Internet Explorer_Server2

Name:

Advanced (Class): [CLASS:Internet Explorer_Server; INSTANCE:2]

ID:

Text: msg display control

Position: 180, 74

Size: 651, 717

ControlClick Coords: 395, 329

Style: 0x56000000

ExStyle: 0x00000000

Handle: 0x00020712

>>>> Mouse <<<<

Position: -335, 620

Cursor ID: 2

Color: 0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

Recent Emails

IM

msg display control

rbottom container window

msg input control

tool bar

EXPAND

Button8

FULLSCREEN

>>>> Hidden Text <<<<

Join

Dismiss

Start

re-activate your subscription

Conversation

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Recent Emails

IM

Send

Tree1

Remove

Email

Click Address Book or type the screen name or email to add.

// some testing code

AutoItSetOption("WinDetectHiddenText", 1);

AutoItSetOption("WinSearchChildren",1);

$text2 = WinGetText ("[CLASS:TriChatFrame]","");

$text3 = WinGetClassList("[CLASS:TriChatFrame]","");

$text1 = ControlGetText("[CLASS:TriChatFrame]","message display control","");

$text4= ControlGetText("[CLASS:TriChatFrame]","","message display control");

$text5 = ControlGetText("[CLASS:TriChatFrame]","","Internet Explorer_Server");

$text5 = ControlGetText("[CLASS:TriChatFrame]","","[CLASS:Internet Explorer_Server; INSTANCE:2]");

msgbox(4096,"",$text1, 2);

msgbox(4096,"",$text2, 10);

msgbox(4096,"",$text3, 10);

msgbox(4096,"",$text4, 2);

msgbox(4096,"",$text5, 2);

Share this post


Link to post
Share on other sites



I found IE.au3 in the AutoIT Help files... but:

Is there a reference available for these IE.udf functions?

Share this post


Link to post
Share on other sites

I found IE.au3 in the AutoIT Help files... but: is there a reference on the IE.udf functions?

Share this post


Link to post
Share on other sites

I found IE.au3 in the AutoIT Help files... but:

Is there a reference available for these IE.udf functions?

Didn't see the list of all UDF's in the helpfile under "IE management"?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

We're talking about the same thing by different names. UDF means users defined functions.

I'll work to get the code working using these fuctions.

Thank you!

Share this post


Link to post
Share on other sites

Still have problems... This issue is very close to another thread:

Can we please work their thread as they have multiple people with the same issue?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Still have problems... This issue is very close to another thread:

Can we please work their thread as they have multiple people with the same issue?

Lets stick to this thread and you show us what you have and what you have problems with.

(removed your resurrection post)

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

As you can imagine, a lot of this code is borrowed from the other post.

I've check the hwnd and the control handle and they're correct.

However the DLL call to oleacc.dll ObjectFromLResult Gives error 1 on lResult 0.

I can't figure it out.

#include <IE.au3>
;#############################;#############################
Func _ObjGetFromHWND(ByRef $hWin)
    DLLCall("ole32.dll","int","CoInitialize","ptr",0)
    If @error Then 
        msgbox(4096,"Failed","No OLE32 CoInitialize PTR", 1);
        Return SetError(@error,@extended,0)
    EndIf

    Local Const $WM_HTML_GETOBJECT = _RegisterWindowMessage("WM_HTML_GETOBJECT")
    If @error Then 
        msgbox(4096,"Failed","WM HTML GETOBJECT failed _REGWINDOWMESSAGE", 1);
        Return SetError(@error,@extended,0)
        EndIf
    
    Local Const $SMTO_ABORTIFHUNG = 0x0002
    Local $lResult, $typUUID, $aRet, $oIE

    _SendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 10000, $lResult)
    If @error Then 
        msgbox(4096,"Failed","SEndMessageTimeout Failed", 1);
        Return SetError(@error,@extended,0)
        EndIf

    $typUUID = DLLStructCreate("int;short;short;byte[8]")
    DLLStructSetData($typUUID,1,0x626FC520)
    DLLStructSetData($typUUID,2,0xA41E)
    DLLStructSetData($typUUID,3,0x11CF)
    DLLStructSetData($typUUID,4,0xA7,1)
    DLLStructSetData($typUUID,4,0x31,2)
    DLLStructSetData($typUUID,4,0x0,3)
    DLLStructSetData($typUUID,4,0xA0,4)
    DLLStructSetData($typUUID,4,0xC9,5)
    DLLStructSetData($typUUID,4,0x8,6)
    DLLStructSetData($typUUID,4,0x26,7)
    DLLStructSetData($typUUID,4,0x37,8)

    $aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _
            "ptr", DLLStructGetPtr($typUUID), "int", 0, "idispatch_ptr", "")
    If @error Then 
        msgbox(4096,"Failed","DllCall Failed: oleacc.dll > ObjectFromLresult Error" & @error & " lR: " & $lResult, 10);
        Return SetError(@error,@extended,0)
    EndIf

    If Not IsObj($aRet[4]) Then 
        msgbox(4096,"Failed","Not ISOBJ~80", 1);
        Return SetError(1,@extended,0)
        EndIf

    $oIE = $aRet[4].Script()
; $oIE is now a valid IDispatch object
;Return $oIE.document.parentwindow
    Return $oIE
EndFunc
;#############################;#############################
Func _RegisterWindowMessage($sMsg)
    Local $aRet = DllCall("user32.dll", "int", "RegisterWindowMessage", "str", $sMsg)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aRet[0]
EndFunc; _RegisterWindowMessage()
;#############################;#############################
Func _SendMessageTimeout($hWnd, $msg, $wParam, $lParam, $nFlags, $nTimeout, ByRef $vOut, $r = 0, $t1 = "int", $t2 = "int")
    Local $aRet = DllCall("user32.dll", "long", "SendMessageTimeout", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam, "int", $nFlags, "int", $nTimeout, "int_ptr", "")
    If @error Then
        $vOut = 0
        msgbox(4096, "_SendMessageTimeout","Failed with error" & @error,10);
        Return SetError(@error, @extended, 0)
    EndIf
    $vOut = $aRet[7]
    If $r >= 0 And $r <= 4 Then Return $aRet[$r]
    Return $aRet
EndFunc; _SendMessageTimeout()

;#############################;#############################

_IEErrorHandlerRegister()

$h_Win = WinGetHandle("[CLASS:TriChatFrame]"); // verified as correct h_win
msgbox(4096,"",$h_Win, 10);
WinActivate($h_Win)
$h_Ctrl = ControlGetHandle($h_Win, "", "[CLASS:Internet Explorer_Server; INSTANCE:2]") ; // verified as corrent h_control

msgbox(4096,"",$h_Ctrl, 10);

$o_IE = _ObjGetFromHWND($h_Ctrl);
msgbox(4096,"",$o_IE, 10);

If IsObj($o_IE) Then
    ConsoleWrite("Got the IE Object" & @CRLF)
    $sHTML = _IEBodyReadHTML($o_IE)
    $hFile = FileOpen("McAfee_HTML.txt", 2)
    FileWrite($hFile, $sHTML)
    FileClose($hFile)
    Run("notepad.exe McAfee_HTML.txt")
Else
    ConsoleWrite("Failed to get IE Object" & @CRLF)
EndIf

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Seems a little comlicated that, are they functions from the IE udf?

try

#include <IE.au3>


$o_IE = _IECreate("www,website.web")

If IsObj($o_IE) Then
    ConsoleWrite("Got the IE Object" & @CRLF)
    $sHTML = _IEBodyReadHTML($o_IE)
    If FileWrite("McAfee_HTML.txt", $sHTML) Then
       Run("notepad.exe McAfee_HTML.txt")
    EndIf
Else
    ConsoleWrite("Failed to get IE Object" & @CRLF)
EndIf
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Definately complicated.

I'm going through all of this because I'm trying to read a window which already exists embedded in another application.

I can read from standalone IE windows fine.

Any ideas?

Seems a little comlicated that, are they functions from the IE udf?

try

#include <IE.au3>


$o_IE = _IECreate("www,website.web")

If IsObj($o_IE) Then
    ConsoleWrite("Got the IE Object" & @CRLF)
    $sHTML = _IEBodyReadHTML($o_IE)
    If FileWrite("McAfee_HTML.txt", $sHTML) Then
       Run("notepad.exe McAfee_HTML.txt")
    EndIf
Else
    ConsoleWrite("Failed to get IE Object" & @CRLF)
EndIf

Share this post


Link to post
Share on other sites

A little more information:

This control item is a child of the window, shell embedding and shell docobjectview.

Window 000B079A "" AtlAxWin90

>Window 0006078E "" Shell Embedding

>>Window 000607B0 "" Shell DocObject View

>>>Window 000607AC "msg input control" Internet Explorer_Server

The results when I try to get the control text:

<00001> 00080772 S message:0xC202 [Registered:"WM_HTML_GETOBJECT"] wParam:00000000 lParam:00000000

<00002> 00080772 R message:0xC202 [Registered:"WM_HTML_GETOBJECT"] lResult:0000C078

<00003> 00080772 S message:0xC202 [Registered:"WM_HTML_GETOBJECT"] wParam:00000000 lParam:00000000

<00004> 00080772 R message:0xC202 [Registered:"WM_HTML_GETOBJECT"] lResult:0000C079

<00005> 00080772 S message:0xC202 [Registered:"WM_HTML_GETOBJECT"] wParam:00000000 lParam:00000000

<00006> 00080772 R message:0xC202 [Registered:"WM_HTML_GETOBJECT"] lResult:0000C07A

I haven't figured out how to read it yet. Any information you might have will be useful.

Share this post


Link to post
Share on other sites

I get to the point where it runs oleacc!OBjectFromLResult()and I get a COM -2147467259 error. Anyone have a lookup for this?

$aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _

"ptr", DLLStructGetPtr($typUUID), "int", 0, "dword_ptr", DllStructGetPtr($idispatch_pointer));

; -2147467259

; 25010648

; 0x017CA950

; 0

; 24948576

#include <IE.au3>
#include <WinAPI.au3>
#Include <SendMessage.au3>

;#############################;#############################
Func _ObjGetFromHWND(ByRef $hWin)
    DLLCall("ole32.dll","int","CoInitialize","ptr",0)
    If @error Then 
        msgbox(4096,"Failed","No OLE32 CoInitialize PTR", 1);
        Return SetError(@error,@extended,0)
    EndIf

    Local Const $WM_HTML_GETOBJECT = _RegisterWindowMessage("WM_HTML_GETOBJECT")
    If @error Then 
        msgbox(4096,"Failed","WM HTML GETOBJECT failed _REGWINDOWMESSAGE", 1);
        Return SetError(@error,@extended,0)
    EndIf
    
    Local Const $SMTO_ABORTIFHUNG = 0x0002;
    Local $lResult, $typUUID, $aRet, $oIE

    _SendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult);
    $errmsg  = _WinAPI_GetLastErrorMessage();
    
    If @error Then 
        msgbox(4096,"Failed","SEndMessageTimeout Failed " & @error & "E EM " & $errmsg, 15);
        Return SetError(@error,@extended,0)
    EndIf

    $typUUID = DLLStructCreate("int;short;short;byte[8]")
    DLLStructSetData($typUUID,1,0x626FC520)
    DLLStructSetData($typUUID,2,0xA41E)
    DLLStructSetData($typUUID,3,0x11CF)
    DLLStructSetData($typUUID,4,0xA7,1)
    DLLStructSetData($typUUID,4,0x31,2)
    DLLStructSetData($typUUID,4,0x0,3)
    DLLStructSetData($typUUID,4,0xA0,4)
    DLLStructSetData($typUUID,4,0xC9,5)
    DLLStructSetData($typUUID,4,0x8,6)
    DLLStructSetData($typUUID,4,0x26,7)
    DLLStructSetData($typUUID,4,0x37,8)

    ;$aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _
    ;        "ptr", DLLStructGetPtr($typUUID), "int", 0, "idispatch_ptr", "")
    
    WinActivate("[CLASS:TriChatFrame]"); 

    $idispatch_pointer = DllStructCreate("dword_ptr");
    $aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _
            "ptr", DLLStructGetPtr($typUUID), "int", 0, "dword_ptr", DllStructGetPtr($idispatch_pointer));
        
    If @error Then 
        ; // error 1 is unable to use he dll file
        msgbox(4096,"Failed","DllCall Failed: oleacc.dll > ObjectFromLresult Error" & @error & " lR: " & $lResult, 10);
        
        msgbox(4096,"Dll Call Results", "" & "=oleacc!ObjectFromLResult() = ",$errmsg); 
        Return SetError(1,@extended,0);
    EndIf

    If IsArray($aRet) Then
        $output = "$ARET: " & @CRLF
        For $r = 0 to UBound($aRet,1) - 1
            $output = $output & "#" & $r & '. ' & $aRet[$r] & @LF
            
        Next
        ConsoleWrite("Array Return Contents"&  @LF & @LF & $output & @LF)
    EndIf
; -2147467259
; 25010648
; 0x017CA950
; 0
; 24948576

    ConsoleWrite(ObjName($aRet[4]));
    $idispatch_pointer=$aRet[4];
    ;$idispatch_pointer=DllStructGetData($idispatch_pointer,1);     
    If @error Then 
        msgbox(4096,"DllStructGEtData failed", @error & @extended);
        Return;
    EndIf

    ConsoleWrite("Returned:" & @LF & "olcacc!objectfromlresult " & $aRet  &  "PTR: " &  $idispatch_pointer & " IsObject : " & IsObj($idispatch_pointer));  
    
    If Not IsObj($aRet[4]) Then 
        If Not IsObj($idispatch_pointer) Then
            msgbox(4096,"Failed", $idispatch_pointer & " & is not an object.", 1);
            Return SetError(1,@extended,0)
            EndIf
        EndIf

    $oIE = $idispatch_pointer.Script();

    $oIE = $aRet[4].Script();
; $oIE is now a valid IDispatch object
;Return $oIE.document.parentwindow
    Return $oIE
EndFunc
;#############################;#############################
Func _RegisterWindowMessage($sMsg)
    Local $aRet = DllCall("user32.dll", "int", "RegisterWindowMessage", "str", $sMsg)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aRet[0]
EndFunc; _RegisterWindowMessage()
;#############################;#############################
Func _SendMessageTimeout($hWnd, $msg, $wParam, $lParam, $nFlags, $nTimeout, ByRef $vOut, $r = 0, $t1 = "int", $t2 = "int")
    
    $vOut = DllStructCreate("dword_ptr");
    ;$vOut = DllStructCreate("int_ptr");
    Local $aRet = DllCall("user32.dll", "long", "SendMessageTimeout", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam, "int", $nFlags,   "int", $nTimeout, "dword_ptr", DllStructGetPtr($vOut));
    ;Local $aRet = DllCall("user32.dll", "long", "SendMessageTimeout", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam, "int", $nFlags,  "int", $nTimeout, "int_ptr", DllStructGetPtr($vOut));
    $vOut = DllStructGetData($vOut,1);
    
    $r = $aRet[0]; // this is the return value, 0 = timeout, 1 = message delivered
    ConsoleWrite("_SendMessageTimeout(" & $hWnd &  "," & $msg &  "," & $wParam &  "," & $lParam &  "," & $nFlags &  "," & $nTimeout &  "," & $vOut & ");");
    ConsoleWrite("_SendMessageTimeout(" & $aRet[0] &  ", wnd=" & $aRet[1] &  ", msg=" & $aRet[2] &  ", wparam=" & $aRet[3] &  ", lparam=" & $aRet[4]  &  "," & $aRet[5]  &  "," & $aRet[6]  & "," &  $aRet[7] & ");");
    
    If @error Then
        $vOut = 0
        ConsoleWrite("_SendMessageTimeout" & @LF & "Failed with error" & @error);
        Return SetError(@error, @extended, 0)
    EndIf
    
    $vOut = $aRet[7]; // value should be returned in item 7
    
    ConsoleWrite("_SendMessageTimeout($hWnd, $msg, ...)" &@LF &"Returned with status code (1=success):'" & $aRet[0] & "' vOut: " & $vOut);
    
    ; return vOut as the seventh param?
    ; this does nothing, why bother?
    ;If $r >= 0 And $r <= 4 Then Return $aRet[$r]
    ;Return $aRet[0]
EndFunc; _SendMessageTimeout()

;#############################;#############################

_IEErrorHandlerRegister();
$h_Win = WinGetHandle("[CLASS:TriChatFrame]"); // verified as correct h_win
WinActivate($h_Win)
$h_Ctrl = ControlGetHandle($h_Win, "", "[CLASS:Internet Explorer_Server; INSTANCE: 2]") ; // verified as corrent h_control

$o_IE = _ObjGetFromHWND($h_Ctrl);

If IsObj($o_IE) Then
    ConsoleWrite("Got the IE Object" & @CRLF)
    $sHTML = _IEBodyReadHTML($o_IE)
    $hFile = FileOpen("McAfee_HTML.txt", 2)
    FileWrite($hFile, $sHTML)
    FileClose($hFile)
    Run("notepad.exe McAfee_HTML.txt")
Else
    ConsoleWrite("Failed to get IE Object" & @CRLF)
EndIf

Share this post


Link to post
Share on other sites

I used this code to log my chats... It will work with Yahoo Instant Messenger or Cisco WebEx Connect. Anything that uses Internet Explorer_Server.

Note: Your instance may be instance:2. Be sure to trap accordingly or use a FOR.

Snippets:

$h_Win = WinGetHandle("[CLASS:TriChatFrame]"); // verified as correct h_win
$h_Ctrl = ControlGetHandle($h_Win, "", "[CLASS:Internet Explorer_Server; INSTANCE: 1]") ; // verified as corrent h_control, instances moving target

; VEry Important note IE must be modified to return $aRet[4];. There is not a script tag, nor a parent I can find so it bombs. Modify IE.iue before running

$o_IE  = __IEControlGetObjFromHWND($h_Ctrl);
    
if objname($o_IE) <> "DispHTMLDocument" Then
    echo ("Unable to locate DispHTMLdocument.");
    Return;
EndIf
    
$HTML = $o_IE.body.innerHTML;   

;~~ modification to IE!Func __IEControlGetObjFromHWND(ByRef $hWin) after oleacc!objectfromlresult call.
    If IsObj($aRet[4]) Then
    ;   ConsoleWrite("Have object!!!" & @CRLF & $aRet[4]);
        return $aRet[4];
    EndIf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0