Jump to content
Sign in to follow this  
chachew

IE page refresh kills script

Recommended Posts

chachew

My script is monitoring a page and changing some text on screen, script works fine until the page is refreshed...then it kills the script with error:

C:\Program Files (x86)\AutoIt3\Include\IE.au3 (3013) : ==> The requested action with this object has failed.:

$oTemp.innerText = $newvalue

$oTemp.innerText = $newvalue^ ERROR

Is there a way to keep the script running regardless of if there is a momentary lapse in form read?

#include <IE.au3>
 
$oIE=_IECreate("...\Test.html")
$varForm=_IEFormGetObjByName($oIE,"form1")
 
While 1
$varText=_IEGetObjById($oIE,"line1")
$varTextGet=_IEPropertyGet($varText, "innertext")
Sleep(1000)
_IEPropertySet($varText,"innertext","This is the result of the script changing the text")
WEnd

Attached is the test.html file i am trying this on.

Test.html

Share this post


Link to post
Share on other sites
trancexx

Of course. You need to add, what's known as COM error handler. The key function is ObjEvent(). Read about it in help file.

If you would have problems then, ask again.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
chachew

After reading about the COM error handling, not sure where to begin..Im guessing if an error occurs to tell the function to restart?

Share this post


Link to post
Share on other sites
UEZ

Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")
;your code

Func ObjErrorHandler()
    ConsoleWrite("A COM Error has occured!" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _
            "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _
            "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _
            )
EndFunc   ;==>ObjErrorHandler

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
chachew

That works UEZ, thanks.

Question is why does this work, this is new to me...sorry for a n00b question. I guess the original way that i had it written, when the error occurred, autoit didnt know how to handle the error so it fails. The ObjEvent() captures those events and does what ever the function specifies based on the error type? Am i understanding this correctly?

Thanks for your help

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  

×