Jump to content

Wait for IE page to load before script continues


stod73
 Share

Recommended Posts

Hello all,

I'm new to AutoIT (and scripting in general) and need you help. I'm trying to create a script to automate a web-based process. I would like the script to have a "pause" in it to stop execution of the script until a IE web page completely loads. Anyone have any ideas?

I tried playing around with WinWaitActive which works great for waiting for an active window but doesn't work for my script since the window is active before the page is finished loading. I can put a "sleep" in the script but was hoping there was a more intelligent way of handling this.

Thanks

Link to comment
Share on other sites

Hello all,

I'm new to AutoIT (and scripting in general) and need you help. I'm trying to create a script to automate a web-based process. I would like the script to have a "pause" in it to stop execution of the script until a IE web page completely loads. Anyone have any ideas?

I tried playing around with WinWaitActive which works great for waiting for an active window but doesn't work for my script since the window is active before the page is finished loading. I can put a "sleep" in the script but was hoping there was a more intelligent way of handling this.

Thanks

check out dale's IE.au3. it has functions to handle about anything you'd ever want to do with ie. you could use the optional wait parameter of the _IENavigate() function, or use _IELoadWait() to accomplish the same thing manually. IE.au3 is required for either of those functions, as well as the beta.
Link to comment
Share on other sites

Quite dirty example but it works:

Opt("WinTitleMatchMode", 2)
$url = "http://www.autoitscript.com"
WaitLoad()

Func WaitLoad()
    Dim $state
    Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $url, @ProgramFilesDir)
    WinWaitActive("Microsoft Internet Explorer")
    Do
        $state = ControlGetText("Microsoft Internet Explorer", "", "msctls_statusbar321")
        Sleep(250)
    Until $state = "XXXXXXXXXX"; Change this with the text that IE displays at the bottom left status bar, after the page is fully loaded. In my computer it says "Completed" in Greek :)
    MsgBox(0, "", "Success!")
EndFunc
Link to comment
Share on other sites

<snipped to know end for brevity>

Until $state = "XXXXXXXXXX"; Change this with the text that IE displays at the bottom left status bar, after the page is fully loaded. In my computer it says "Completed" in Greek :)
    MsgBox(0, "", "Success!")
EndFunc
and in mine, it says "Done" in American english. :-)
Link to comment
Share on other sites

The following using IE.au3 loads the autoitscript page and waits for the load to complete before returing control... in 3 lines and it is language independant :-)

Dale

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "www.autoitscript.com")

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

  • 4 years later...

The following using IE.au3 loads the autoitscript page and waits for the load to complete before returing control... in 3 lines and it is language independant :-)

Dale

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "www.autoitscript.com")

Now if i close this site and reload it 4 to 5 times threw out the script do i have to use that each time or do i just put that at top and every time i load that site it waits?

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...