Jump to content

Wait for page to completely load


Recommended Posts

Hello everybody , i'm trying a scrip in autoit to do something in firefox a lot of times. My problem is that sometimes , the page takes more time to load and then the movement of the mouse might be late or sooner than the loading. Is there any way to tell him to execute the action just after the page finishes loading ? Thanks !

Edited by brokensword02
Link to comment
Share on other sites

Yeah I checked , but it only works the first time you launch IE with Run("...\IE.exe) Then it's gonna wait the page to load to continue the script. But i would want something to make a pause between two actions and tell the next one to wait for the page to load. Not just at the beginning.

Link to comment
Share on other sites

Try using the IE functions. You can create your own instance of IE, hidden or shown, as well as attach to existing instances of IE. Then just navigate to the page you want to wait for with the IE functions, and put something like _IEPropertyGet($oIE, "busy") in a loop until it is no longer working on loading the page.

EDIT:

The IE function _IENavigate has a built in option for waiting for the page to load. So you have many options. Here are a few that would work:

#include <IE.au3>
_IEErrorHandlerRegister()

$oIE = _IECreate("about:blank")
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php"); (Default) Wait for page load to complete before returning
MsgBox(0, 'Done', 'Done loading page')
_IEQuit($oIE)

;OR WITH IE PROPERTY

$oIE = _IECreate("about:blank")
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php", 0) ;Return immediately, not waiting for page to load
While _IEPropertyGet($oIE, "busy") = True
    Sleep(50); wait while IE is busy
WEnd
MsgBox(0, 'Done', 'Done loading page' & @CRLF & "-Open your own instance of IE for the next method.")
_IEQuit($oIE)

;OR WITH ATTACH

$oIE = _IEAttach('', 'Instance')
If @error Then
    MsgBox(0, 'Error', 'No instance of IE to attach to.')
Else
    _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php") ;Default) Wait for page load to complete before returning
    MsgBox(0, 'Done', 'Done loading page')
    _IEQuit($oIE)
EndIf
Edited by danwilli
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...