JDHabit Posted July 2, 2020 Share Posted July 2, 2020 I wanted a simple bot that helps me look up my favorite manga side, search for a button that only exists when a new chapter has been updated and leave the open window for me to read when I come back. Sometimes this works perfectly fine and sometimes it somehow gets an error. I have no idea why he gets it. as it is random which chapter gives the error and which doesn't. I also have run throughts where there is no error at all. Wanting to just ask again if it fails I added the if @error Then statement that I've seen before but somehow if the error happens AutoIt3.exe simply stops. Func lookForUpdate($link) $ie = ObjCreate ("InternetExplorer.Application") With $ie .visible = True .navigate($link) While($ie.busy) WEnd Sleep(3500) $button = .document.getElementsByTagName("a") If @error Then _IEQuit($ie) lookForUpdate($link) Else $found = False For $b in $button if $b.innerHTML = "NEXT CHAPTER" Then $found= True ConsoleWrite($link) ExitLoop EndIf Next If Not $found Then _IEQuit($ie) EndIf EndIf EndWith EndFunc Link to comment Share on other sites More sharing options...
JDHabit Posted July 2, 2020 Author Share Posted July 2, 2020 the Error message is that "==> The requested action with this object has failed.:" and $button = .document.getElementsByTagName("a") is the marked line in my code. When I get that message I would like the system to continue on and try again. Link to comment Share on other sites More sharing options...
TheXman Posted July 2, 2020 Share Posted July 2, 2020 (edited) You cannot catch @error after a COM statement without a custom COM error handler. Without a custom COM error handler, the script just stops with an error, as you have been experiencing. The custom COM error handler doesn't have to do anything in particular, it just has to exist so that you can process the statement after the COM statement that had the error. Carefully read and look at the example under COM Error Handling, in the Help file, under the COM Reference topic:https://www.autoitscript.com/autoit3/docs/intro/ComRef.htm Edited July 2, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
JDHabit Posted July 2, 2020 Author Share Posted July 2, 2020 Thanks for the Link, I now got a Com Error Handler, and he gives me the necessary info that I got a wrong Variable Type. Randomly. Sadly the bot still terminates. I did a few small edits to my function, having it now return an boolean at the end if it ran into an error. which is does but then AutoIt3.exe still stops. Since I'm calling the method more then once I simply wanted it to give me the failed check and move on. for $s = 0 to 19 Step +1 if Not lookForUpdate($arr[$s]) Then ConsoleWrite("Error for Number " & $s) EndIf Next and while it does write down the error. when it randomly starts not working in the middle the array every following doesn't work until it terminates a little before the actual end of the list. So while the error handler works to some degree it doesn't fully. But for this thread my question got answered. 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