Vieri Posted September 6, 2007 Share Posted September 6, 2007 The following script gives unusual behavior. Sometimes it shows COM errors and hangs or in other cases it executes fine "apparently" (all on Windows XP Pro). Has anyone already mixed COM and _IECreate in one single script successfully? I might be missing something trivial. The code: expandcollapse popupOpt("TrayMenuMode",1) Dim $oMyError, $idDocument, $p_idSection, $FHM_TARGET If $CmdLine[0] > 0 Then $p_idSection = $CmdLine[1] Else $p_idSection = "4688b091ae853" EndIf $FHM_TARGET = "http://webserver/app/portal/index.php" $ODBC_UID = "" $ODBC_PWD = "" $ODBC_UID_SECTION = "fhm" $ODBC_PWD_SECTION = "fhm" $ODBC_Driver = "{SQL Server}" $ODBC_SQLServer = "sqlserver" $ODBC_DBASE = "" $sQuery = "SELECT * FROM dbo.prov_userpassword" $sQuery_SECTION = "SELECT * FROM dbo.int_documents, dbo.int_sections, dbo.int_subsections WHERE dbo.int_documents.StartPub >= " & @MDAY & "/" & @MON & "/" & @YEAR & " and dbo.int_subsections.idSectionRow = dbo.int_sections.idSection AND dbo.int_documents.idSection = dbo.int_sections.idSection AND dbo.int_subsections.idSectionOdd = '" & $p_idSection & "'" $adCmdText = 1 $adOpenDynamic = 2 $adLockOptimistic = 3 $adOpenKeyset = 1 #include <IE.au3> ;#include <GUIConstants.au3> $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $ado = ObjCreate( "ADODB.Connection" ) With $ado .ConnectionString =("DRIVER=" & $ODBC_Driver & ";SERVER=" & $ODBC_SQLServer & ";DATABASE=" & $ODBC_DBASE & ";UID=" & $ODBC_UID_SECTION & ";PWD=" & $ODBC_PWD_SECTION & ";") .Open EndWith if @error Then Exit(1) $adors = ObjCreate( "ADODB.RecordSet" ) With $adors .ActiveConnection = $ado .Source = $sQuery_SECTION .CursorType = $adOpenKeyset .LockType = $adLockOptimistic .Open EndWith if @error Then Exit(1) $FHM_REC_COUNT = $adors.RecordCount If $FHM_REC_COUNT > 0 Then SRandom(@SEC) $FHM_REC_RAND = Random ( 0, $FHM_REC_COUNT, 1 ) If not $adors.EOF Then $adors.Move($FHM_REC_RAND) $idDocument = $adors.Fields( "idDocument" ).Value EndIf $FHM_TARGET &= "?IDDOCUMENT=" & $idDocument & "&IDSECTION=" & $p_idSection EndIf $adors.Close $ado.Close if @error Then Exit(1) ; $ado = ObjCreate( "ADODB.Connection" ) With $ado .ConnectionString =("DRIVER=" & $ODBC_Driver & ";SERVER=" & $ODBC_SQLServer & ";DATABASE=" & $ODBC_DBASE & ";UID=" & $ODBC_UID & ";PWD=" & $ODBC_PWD & ";") .Open EndWith if @error Then Exit(1) ; $adors = ObjCreate( "ADODB.RecordSet" ) With $adors .ActiveConnection = $ado .Source = $sQuery .CursorType = $adOpenKeyset .LockType = $adLockOptimistic .Open EndWith if @error Then Exit(1) $FHM_PWD = "" While not $adors.EOF ; MsgBox(0, "DEBUG", "PWD is: " & $adors.Fields( "password" ).Value) $FHM_PWD = $adors.Fields( "password" ).Value $adors.MoveNext WEnd $adors.Close $ado.Close if @error Then Exit(1) $adors = 0 ; $ado.Quit () $ado = 0 $oIE = _IECreate ($FHM_TARGET, 0, 1, 1) if @error Then Exit(1) $oForm = _IEFormGetObjByName ($oIE, "form1") if @error Then Exit(1) $oQuery = _IEFormElementGetObjByName ($oForm, "username") if @error Then Exit(1) _IEFormElementSetValue ($oQuery, @UserName) if @error Then Exit(1) $oQuery = _IEFormElementGetObjByName ($oForm, "password") if @error Then Exit(1) _IEFormElementSetValue ($oQuery, $FHM_PWD) if @error Then Exit(1) _IEFormSubmit ($oForm) if @error Then Exit(1) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) If stringlen($oMyError.description) > 0 Then Msgbox(0,"ERROR","COM error in " & @ScriptName & @CRLF & @CRLF & _ "Description: " & @TAB & $oMyError.description & @CRLF & _ "Windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "Number: " & @TAB & $HexNumber & @CRLF & _ "Last dll error: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "Scriptline: " & @TAB & $oMyError.scriptline & @CRLF & _ "Source: " & @TAB & $oMyError.source & @CRLF & _ "Help file: " & @TAB & $oMyError.helpfile & @CRLF & _ "Help context: " & @TAB & $oMyError.helpcontext _ ) EndIF SetError(1); to check for after this function returns Endfunc Link to comment Share on other sites More sharing options...
DaleHohm Posted September 6, 2007 Share Posted September 6, 2007 (edited) Are you running this from SciTe? Hopefully so -- IE.au3 writes a lot of diagnostics to the SciTe console. One comment is that IE.au3 cannot use its internal error handler if you make your own call to ObjEvent AutoItError. Please see _IEErrorHandlerRegister in the helpfile -- the IE.au3 COM error handler does what yours does and more, but if you want to use yours, _IEErrorHandlerRegister gives you a way to do it that does not conflict. As mentioned above, you should see a message in the SciTe console that tells you this. Beyond that, there are no general issues with what you describe and you'll need to narrow down your trouble further. Dale Edit: typo Edited September 6, 2007 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Vieri Posted September 7, 2007 Author Share Posted September 7, 2007 Are you running this from SciTe?One comment is that IE.au3 cannot use its internal error handler if you make your own call to ObjEvent AutoItError. Please see _IEErrorHandlerRegisterThanks for the input.I am using SciTe now and I see that I should use _IEErrorHandlerRegister.However, I removed it for testing purposes as it is giving me trouble:;$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")I finally found out that the problem I was getting in just a few hosts was solved by doing_IEFormSubmit ($oForm, 0)_IELoadWait($oIE)instead of_IEFormSubmit ($oForm)(as stated in an example in the help file) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now