_IECreat() error
#1
Posted 19 February 2009 - 02:06 AM
In my script, a line'_IECreate("www.google.com",0 , 1 , 1, 0)' will generate an error, please see the following for the error details:
COM Error with DOM!
err.description is:
err.windescription: 未指定的错误
err.number is: 80020009
err.lastdllerror is: 0
err.scriptline is: 4257
err.source is:
err.helpfile is:
err.helpcontext is: 0
but if I replace '_IECreate("www.google.com",0 , 1 , 1, 0)' with '_IECreate("about:blank",0 , 1 , 1, 0)', the error will not appear.
anyone can help me?
#3
Posted 19 February 2009 - 03:16 AM
#6
Posted 19 February 2009 - 02:05 PM
Thanks, I will look at it.
BTW, my IE.au3 version is V2.4-1.
And how are you reading this XML file? Please post a short reproducer script that causes the symptoms for you.
#7
Posted 24 February 2009 - 09:07 AM
here is my script:And how are you reading this XML file? Please post a short reproducer script that causes the symptoms for you.
Func _Readtemplate($xmlfilename,$path) $sXML = $xmlfilename If _XMLFileOpen($sXML,"",-1) = -1 Then ConsoleWrite("can′t open file!" & @CRLF) Exit EndIf $tmpvalue = _XMLSelectNodes($path) $template = $tmpvalue[1] for $i = 2 to _ArrayMax($tmpvalue) $template =$template&"|"&$tmpvalue[$i] Next EndFunc
#8
Posted 24 February 2009 - 02:29 PM
That's not enough for someone to run it and see your symptoms, but it does prompt a relevant question: Do you have the latest version of XMLDOMWrapper.au3 from eltorro? I believe he made some compatibility changes about a year ago, so his COM error handler would not conflict with others.here is my script:
Func _Readtemplate($xmlfilename,$path) $sXML = $xmlfilename If _XMLFileOpen($sXML,"",-1) = -1 Then ConsoleWrite("can′t open file!" & @CRLF) Exit EndIf $tmpvalue = _XMLSelectNodes($path) $template = $tmpvalue[1] for $i = 2 to _ArrayMax($tmpvalue) $template =$template&"|"&$tmpvalue[$i] Next EndFunc
#9
Posted 25 February 2009 - 01:43 AM
#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <IE.au3> #include <_XMLDomWrapper.au3> #include <GuiTab.au3> Global $template, $tmpvalue _Main() Func _Main() ; Create the GUI window and controls GUICreate("Wing 1.0", 400, 500, (@DesktopWidth - 400)/ 2, (@DesktopHeight - 500) / 2) $OLD = _SetThemes(0) GUISetIcon("Wing_1.ico") $tab = GUICtrlCreateTab(10, 10, 382, 440,0x00000020 ) _SetThemes($OLD) ;~ $tabitem1 = GUICtrlCreateTabItem("aaaa") ;~ $create = GUICtrlCreateButton("Create file", 60, 465, 130, 20) $tabitem2 = GUICtrlCreateTabItem("bbbb") $radioAddreport = GUICtrlCreateRadio("Add bbbb", 25, 45, 160, 20, 000000) $radioAddreporttemplate = GUICtrlCreateRadio("Add cccc", 200, 45, 150, 20, 000000) $bugreporttemplatelabel = GUICtrlCreateLabel("Template", 200, 75, 80, 20, 0x0200) $bugreporttemplate = GUICtrlCreateCombo("", 255, 75, 120, 20) $addreport = GUICtrlCreateButton("Add bbbb", 30, 465, 100, 20) ;~ $updatereport = GUICtrlCreateButton("Update bbbb", 150, 465, 90, 20) ;~ $tabitem1 = GUICtrlCreateTabItem("cccc") GUICtrlCreateTabItem("") $memonumlabel = GUICtrlCreateLabel("Memo #", 25, 75, 80, 20, 0x0200) $memonum = GUICtrlCreateInput("", 105, 75, 80, 20, 0x0080) $cancelbutton = GUICtrlCreateButton("Cancel", 260, 465, 60, 20) ;get bug report template _Readtemplate("data resource\resource.xml", "/wing/report/*") GUICtrlSetData($bugreporttemplate, $template,$tmpvalue[1]) ; Run the GUI until it is closed GUISetState() ControlFocus ( "Wing 1.0", "", $memonum) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton ExitLoop case $msg = $tab if GUICtrlRead($tab) = 0 Then $clickAddreport = ControlClick("Wing 1.0","",$radioAddreport) endif Case $msg = $addreport if GUICtrlRead($memonum) = "" Then MsgBox(4096,"message","Please input memo number",10) Else $oIE = _IECreate("www.google.com") EndIf EndSelect WEnd Exit EndFunc ;==>_Main Func _Readtemplate($xmlfilename,$path) $sXML = $xmlfilename If _XMLFileOpen($sXML,"",-1) = -1 Then ConsoleWrite("can′t open file!" & @CRLF) Exit EndIf $tmpvalue = _XMLSelectNodes($path) $template = $tmpvalue[1] for $i = 2 to _ArrayMax($tmpvalue) $template =$template&"|"&$tmpvalue[$i] Next EndFunc Func _SetThemes($Style) If @OSType = "WIN32_WINDOWS" Or $Style=-1 Then Return SetError(1,0,-1) Local $ret = DllCall("uxtheme.dll", "dword", "GetThemeAppProperties") If Not IsArray($ret) Then Return SetError(1,0,-1) DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "dword", $Style) Return $ret[0] EndFunc
xml file contents is as the follows:
<?xml version="1.0" encoding="utf-8"?> <wing> <report> <PSOreport> <bugreport> <title>title1</title> <sql>select .......</sql> </bugreport> <dashboard> <title>title2</title> <sql>select .......</sql> </dashboard> </PSOreport> <QAtemplate> <bugreport> <title>test title</title> <sql>test sql</sql> </bugreport> <dashboard> <title>test title 1</title> <sql>test sql 1</sql> </dashboard> </QAtemplate> <DEVtemplate> <bugreport> <title>test title 2</title> <sql>TEST SQL 2</sql> </bugreport> <dashboard> <title>test title 3</title> <sql>test sql 3</sql> </dashboard> </DEVtemplate> </report> <readme> <MM /> </readme> </wing>
I have no ideas now, hope your help, thanks.
#10
Posted 25 February 2009 - 07:54 PM
I simplified the reproducer:My _XMLDomWrapper.au3 is the newest. the following is the whole code.
CODE#include <GuiConstantsEx.au3>xml file contents is as the follows:
#include <WindowsConstants.au3>
#include <Array.au3>
#include <IE.au3>
#include <_XMLDomWrapper.au3>
#include <GuiTab.au3>
Global $template, $tmpvalue
_Main()
Func _Main()
; Create the GUI window and controls
GUICreate("Wing 1.0", 400, 500, (@DesktopWidth - 400)/ 2, (@DesktopHeight - 500) / 2)
$OLD = _SetThemes(0)
GUISetIcon("Wing_1.ico")
$tab = GUICtrlCreateTab(10, 10, 382, 440,0x00000020 )
_SetThemes($OLD)
;~ $tabitem1 = GUICtrlCreateTabItem("aaaa")
;~ $create = GUICtrlCreateButton("Create file", 60, 465, 130, 20)
$tabitem2 = GUICtrlCreateTabItem("bbbb")
$radioAddreport = GUICtrlCreateRadio("Add bbbb", 25, 45, 160, 20, 000000)
$radioAddreporttemplate = GUICtrlCreateRadio("Add cccc", 200, 45, 150, 20, 000000)
$bugreporttemplatelabel = GUICtrlCreateLabel("Template", 200, 75, 80, 20, 0x0200)
$bugreporttemplate = GUICtrlCreateCombo("", 255, 75, 120, 20)
$addreport = GUICtrlCreateButton("Add bbbb", 30, 465, 100, 20)
;~ $updatereport = GUICtrlCreateButton("Update bbbb", 150, 465, 90, 20)
;~ $tabitem1 = GUICtrlCreateTabItem("cccc")
GUICtrlCreateTabItem("")
$memonumlabel = GUICtrlCreateLabel("Memo #", 25, 75, 80, 20, 0x0200)
$memonum = GUICtrlCreateInput("", 105, 75, 80, 20, 0x0080)
$cancelbutton = GUICtrlCreateButton("Cancel", 260, 465, 60, 20)
;get bug report template
_Readtemplate("data resource\resource.xml", "/wing/report/*")
GUICtrlSetData($bugreporttemplate, $template,$tmpvalue[1])
; Run the GUI until it is closed
GUISetState()
ControlFocus ( "Wing 1.0", "", $memonum)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
ExitLoop
case $msg = $tab
if GUICtrlRead($tab) = 0 Then
$clickAddreport = ControlClick("Wing 1.0","",$radioAddreport)
endif
Case $msg = $addreport
if GUICtrlRead($memonum) = "" Then
MsgBox(4096,"message","Please input memo number",10)
Else
$oIE = _IECreate("www.google.com")
EndIf
EndSelect
WEnd
Exit
EndFunc ;==>_Main
Func _Readtemplate($xmlfilename,$path)
$sXML = $xmlfilename
If _XMLFileOpen($sXML,"",-1) = -1 Then
ConsoleWrite("can′t open file!" & @CRLF)
Exit
EndIf
$tmpvalue = _XMLSelectNodes($path)
$template = $tmpvalue[1]
for $i = 2 to _ArrayMax($tmpvalue)
$template =$template&"|"&$tmpvalue[$i]
Next
EndFunc
Func _SetThemes($Style)
If @OSType = "WIN32_WINDOWS" Or $Style=-1 Then Return SetError(1,0,-1)
Local $ret = DllCall("uxtheme.dll", "dword", "GetThemeAppProperties")
If Not IsArray($ret) Then Return SetError(1,0,-1)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "dword", $Style)
Return $ret[0]
EndFuncCODE<?xml version="1.0" encoding="utf-8"?>I have no ideas now, hope your help, thanks.
<wing>
<report>
<PSOreport>
<bugreport>
<title>title1</title>
<sql>select .......</sql>
</bugreport>
<dashboard>
<title>title2</title>
<sql>select .......</sql>
</dashboard>
</PSOreport>
<QAtemplate>
<bugreport>
<title>test title</title>
<sql>test sql</sql>
</bugreport>
<dashboard>
<title>test title 1</title>
<sql>test sql 1</sql>
</dashboard>
</QAtemplate>
<DEVtemplate>
<bugreport>
<title>test title 2</title>
<sql>TEST SQL 2</sql>
</bugreport>
<dashboard>
<title>test title 3</title>
<sql>test sql 3</sql>
</dashboard>
</DEVtemplate>
</report>
<readme>
<MM />
</readme>
</wing>
#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <IE.au3> #include <_XMLDomWrapper.au3> ; _IEErrorHandlerRegister; Uncomment this line to fix it Global $template, $tmpvalue ; Create the GUI window and controls GUICreate("Wing 1.0", 400, 500, (@DesktopWidth - 400) / 2, (@DesktopHeight - 500) / 2) $addreport = GUICtrlCreateButton("Add bbbb", 30, 465, 100, 20) $cancelbutton = GUICtrlCreateButton("Cancel", 260, 465, 60, 20) GUISetState() ;Open XML, which loads _XMLCOMError() as the AutoIt COM error handler If _XMLFileOpen(@ScriptDir & "\resource.xml", "", -1) = -1 Then ConsoleWrite("can't open file!" & @CRLF) Exit EndIf ; Run the GUI until it is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Exit Case $msg = $addreport ; Open IE with _IECreate() >> calls _IENavigate() >> calls __IEIsObjType() >> ; which fails running __IEInternalErrorHandlerRegister() $oIE = _IECreate("www.google.com") EndSelect WEnd
This reproduces your error, and if you uncomment the _IEErrorHandlerRegister() it will fix it.
Your call to the XML functions registers an error handler from that UDF, then the IE UDF chokes on it. Dale might want to investigate, because I think IE.au3 is supposed to be OK with another error handler already registered.
Edit: The console output running this demo is:
>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\temp\Test.au3" --> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler) --> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler) --> IE.au3 V2.4-0 Warning from function _IELoadWait, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
To clarify with the OP:
The COM error is referencing .scriptline = 4257 of IE.au3. Changing the URl to about:blank removes the internal call to _IENavigate() and avoids the issue.Hi,
In my script, a line'_IECreate("www.google.com",0 , 1 , 1, 0)' will generate an error, please see the following for the error details:
COM Error with DOM!
err.description is:
err.windescription:
err.number is: 80020009
err.lastdllerror is: 0
err.scriptline is: 4257
err.source is:
err.helpfile is:
err.helpcontext is: 0
but if I replace '_IECreate("www.google.com",0 , 1 , 1, 0)' with '_IECreate("about:blank",0 , 1 , 1, 0)', the error will not appear.
anyone can help me?
Putting _IEErrorHandlerRegister() at the top of your script avoids the problem because the _XMLDOMWrapper() error handler is skipped if one is already loaded.
Edited by PsaltyDS, 25 February 2009 - 08:48 PM.
#11
Posted 25 February 2009 - 10:14 PM
--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType
I use the words Warning and Error very carefully. A warning can be often be ignored, but an Error will likely be a source of trouble.
_IENavigate calls _IELoadWait... _IELoad wait checks the readyState of the document object... we first check to insure it IS a document object... thus the call to __IEIsObjType... while doing a navigation, the current document object is destroyed, but we still attempt to check the document readyState. During the transition until a new document is instantiated, this causes a COM error. There is a lot of internal logic in IE.au3 to hide these expected errors from you and also to prevent them from being fatal.
Ok, so that is the source of the COM errors.
Now, the error handlers... only one COM error handler can be instantiated at a time. IE.au3 does the best it can to allow playing nice with others... it actually installs and deinstalls its internal COM error handler to try to stay out of the way of other code. If another COM error handler is being used, IE.au3 will remove it, install its own and then remove its own and reinstantiate yours... but, only if it can find it!
For IE.au3 to find your error handler, it must either be registered with _IEErrorHandlerRegister, or it must be assigned to the variable $oIEErrorHandler. In fact, if you modify eltorro's code and replace $oXMLMyError with $oIEErrorHandler, the IE.au3 warning and the _XML DOM errors will go away (because IE.au3 can then do the work behind the scenes of registering and deregistering error handlers).
This is exactly what is documented in the remarks for _IEErrorHandlerRegister() in the helpfile.
Dale
edit: clarity
Edited by DaleHohm, 26 February 2009 - 02:01 AM.
#12
Posted 25 February 2009 - 10:52 PM
Please note the exact text of the console message:
--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType
I use the words Warning and Error very carefully. A warning can be often be ignored, but an Error will likely be a source of trouble.
_IENavigate calls _IELoadWait... _IELoad wait checks the readyState of the document object... we first check to insure it IS a document object... thus the call to __IEIsObjType... while doing a navigation, the current document object is destroyed, but we still attempt to check the document readyState. During the transition until a new document is instantiated, this causes a COM error. There is a lot of internal login in IE.au3 to hide these expected errors from you and also to prevent them from being fatal.
Ok, so that is the source of the COM errors.
Now, the error handlers... only one COM error handler can be instantiated at a time. IE.au3 does the best it can to allow playing nice with others... it actually installs and deinstalls its internal COM error handler to try to stay out of the way of other code. If another COM error handler is being used, IE.au3 will remove it, install its own and then remove its own and reinstantiate yours... but, only if it can find it!
For IE.au3 to find your error handler, it must either be registered with _IEErrorHandlerRegister, or it must be assigned to the variable $oIEErrorHandler. In fact, if you modify eltorro's code and replace $oXMLMyError with $oIEErrorHandler, the IE.au3 warning and the _XML DOM errors will go away (because IE.au3 can then do the work behind the scenes of registering and deregistering error handlers).
This is exactly what is documented in the remarks for _IEErrorHandlerRegister() in the helpfile.
Dale
edit: clarity
Seems like what we need is a standard, globaly declared, and universal variable (like $CmdLine or $CmdLineRaw are) for the current error handler. Then every UDF could reference it. A name like $COMErrorHandler would work. If everyone uses $oIEErrorHandler it works too, but the naming convention is not universal. Sounds like a feature request to me... though making it an accepted convention may be the only actual implementation.
Edit: Opened it as a feature request Trac #838.
Edited by PsaltyDS, 25 February 2009 - 11:06 PM.
#13
Posted 27 February 2009 - 07:29 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





