Jump to content

For Next Loop Error Check / Restart step


Recommended Posts

Hi!

I have this script, based on a loop. Sometimes, the webpage I get info off with the script loads to long, or sometimes it does not even load at all.. Is there some way to let the script restart the step when it errors, or move to another part of the script entirely?

Thanks in advance!

Link to comment
Share on other sites

Hi!

I have this script, based on a loop. Sometimes, the webpage I get info off with the script loads to long, or sometimes it does not even load at all.. Is there some way to let the script restart the step when it errors, or move to another part of the script entirely?

Thanks in advance!

If you can show your script file, maybe be easier to solve what you want.

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

If you can show your script file, maybe be easier to solve what you want.

Qft.

There are two ways that I can think of off the top of my head:

1. You could check a certain spot on the webpage, and see if it has the color pixel that it would have if it's loaded.

2. (Using IE) You can mess around with the IE functions that AutoIT has built in, and see if one of those has what you need. <disclaimer> I don't use IE, so I have no clue if this'll be what you need, however </disclaimer>

But again, seeing your code would be helpful.

-Pandemic

Link to comment
Share on other sites

Here is something I did to check to see if my program has logged in...

Do
    Sleep(1000)
    If Not WinActive("Operator View - Mozilla Firefox","") Then     
        Sleep(1000)
        Send("^l")
        Sleep(500)
        Send("^v{ENTER}")
        Sleep(1500)
        WinWaitActive("Mozilla Firefox","",5)
            If WinActive("Mozilla Firefox","") Then
                Send($username & "{tab}" & $password & "{tab 2}{space}")
            EndIf
        Sleep(1500)
    EndIf
Until WinActive("Operator View - Mozilla Firefox","")

Now this is very simple but it repeats all the steps until the correct page is loaded. It does require the page name to be different but normally different pages are different.

Let me know if this has helped

Link to comment
Share on other sites

Great thanks!

I've improved my script with:

_IELoadWait ($oIE), after each load period, works like a charm! WinActive command is also quite usefull, since I use Excel & IE..

I was wondering, for example with _IEFormELementGetObjByName command, how do I return the @error code?

If I could return the erro code, i'll just check it each time if it isn't 0 (succes=no error), and if it is something else, I'll exit the loop.. Anyone any idea?

Edited by ThomasQ
Link to comment
Share on other sites

After each command, with a possibilty to fail you can use this:

If @error <> 0 Then

Whateveryouwanttodo

Endif

In My case

If @error <> 0 Then

ExitLoop

Endif

whereafter it exits the loop, and continues after the loop, wich is basicly a reset combo, and then it starts up again..

Thanks for the help/ideas, good luck with your scripts!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...