Jump to content
Sign in to follow this  
johnz

Problem regarding automating embedded internet explorer_server

Recommended Posts

johnz

Hi Guys,

I need to access an embedded instance of internet explorer. I tried using the _IEAttach method passing the Window name and "embedded" as the mode but no success with that. So i broke up the calls to internal functions of IE.au3 and found that a call to function DllCall is returning an error. Here's what my code looks like:

$handle = WinGetHandle("Window Name")

_IEErrorHandlerRegister()

WinActivate($handle)

$h_Ctrl = ControlGetHandle($handle, "", "[Class:Internet Explorer_Server]")

$o_IE = ___IEControlGetObjFromHWND($h_Ctrl)

MsgBox(0, "Error Status", @error)

Inside the ___IEControlGetObjFromHWND function:

Func __IEControlGetObjFromHWND(ByRef $hWin)

DllCall("ole32.dll", "int", "CoInitialize", "ptr", 0)

Local Const $WM_HTML_GETOBJECT = __IERegisterWindowMessage("WM_HTML_GETOBJECT")

Local Const $SMTO_ABORTIFHUNG = 0x0002

Local $lResult, $typUUID, $aRet, $oIE

__IESendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult)

MsgBox(0, "Result", $lResult)

$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", "")

MsgBox(0, "Error", @error)

If IsObj($aRet[4]) Then

$oIE = $aRet[4].Script ()

; $oIE is now a valid IDispatch object

Return $oIE.document.parentwindow

Else

SetError(1)

Return 0

EndIf

EndFunc

After the DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, "ptr", DllStructGetPtr($typUUID), "int", 0, "idispatch_ptr", ""), i placed a msgbox to get the error which as it turns out is 2. According to the help file, @error = 2 unknown "return type".

So whats going wrong here? I am actually trying to get control of the embedded browser so that I can navigate around and get/post data.

Any help in this regard will be highly appreciated.

Thanks.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.