Jump to content

How to find out when a page is done loading


Recommended Posts

I use AutiIt to copy/paste a lot of text from one website to another.

Sometimes the server is slow and then my script fucks up because its trying to continue before the page is done loading.

Can u somehow get the script to check for that?

Link to comment
Share on other sites

If you use AutoSpy to watch a page as it loads, have a look at the section called Status Bar Text.

You can monitor this from your script, and continue only when the right message appears.

EG: (using MSIE), while loading a page, mine gives a whole list of messages while the page is loading, and then a final one that says Done, when it has finished.

This might be different depending on the site(s) and browser you're using. Which is why you need to use AutoSpy to see what's good for you :D

Edited by trids
Link to comment
Share on other sites

..OR..

You can monitor the animation that plays while a file is loading: when a pixel stays the same for a second or two, then you can assume the load has finished.

In MSIE, the animation I'm referring to is the logo in the top right corner, that revolves around a globe.

Again, monitor a page with AutoSpy .. and see how the Pixel Colour Under Mouse section changes while you hover your mouse over the logo.

See the help file for AutoItSetOption ("PixelCoordMode",param) and PixelGetColor if you want to use this approach.

Hope this helps :D

Link to comment
Share on other sites

  • Administrators

..OR..

You can monitor the animation that plays while a file is loading: when a pixel stays the same for a second or two, then you can assume the load has finished.

In MSIE, the animation I'm referring to is the logo in the top right corner, that revolves around a globe.

Again, monitor a page with AutoSpy .. and see how the Pixel Colour Under Mouse section changes while you hover your mouse over the logo.

See the help file for AutoItSetOption ("PixelCoordMode",param) and PixelGetColor if you want to use this approach.

Hope this helps  :D

The PixelChecksum() function in the new unstable is also cool for things like that.
Link to comment
Share on other sites

Thank you all very much.

I have choosen SlimShady solution because then my scirpt will work on all IE browses no matter what "page is loading" image it's using.

Now i only have one question SlimShady. If the page is reel heavy and take a long time to load the scripts stops.

Why?

Link to comment
Share on other sites

This is what I use,seems to work like a charm

$MousePos = MouseGetPos()

$CursorActivity = MouseGetCursor()

Do

Sleep(500)

MouseMove(100, 1, 0)

$CursorActivity = MouseGetCursor()

Until $CursorActivity = 2 And StatusbarGetText(WinGetTitle("")) = "Done"

MouseMove($MousePos[0], $MousePos[1], 0)

Link to comment
Share on other sites

I don't understand. I use this as an example and it works perfect:

AutoItSetOption("WinTitleMatchMode", 2)

Run("explorer http://www.msn.com")

WinWait("Internet Explorer")
Sleep(1000)
WinSetState("Internet Explorer", "", @SW_MAXIMIZE)

MouseMove(100, 1, 0)

$x = MouseGetCursor()

Do
$x = MouseGetCursor()
Sleep(500)
Until $x = 2
Link to comment
Share on other sites

This is what I use,seems to work like a charm

  $MousePos = MouseGetPos()

  $CursorActivity = MouseGetCursor()

  Do

      Sleep(500)

      MouseMove(100, 1, 0)

      $CursorActivity = MouseGetCursor()     

  Until $CursorActivity = 2 And StatusbarGetText(WinGetTitle("")) = "Done"

  MouseMove($MousePos[0], $MousePos[1], 0)

Got this from Larry a long time ago and edited it a bit

func pageloaded($a)

MouseMove(0,0)

$bSure = 0

While $bSure < 5

$ret=StatusBarGetText($a) == "Done"

If StatusBarGetText($a) == "Done" or StatusBarGetText($a) =="" then

$bSure = $bSure + 1

Else

$bSure = 0

EndIf

Sleep(150)

Wend

;MsgBox(4096, "AutoIt", $ret)

;Return $a

EndFunc

;Rick

Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

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