Sign in to follow this  
Followers 0
falslev

How to find out when a page is done loading

16 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

It's correct that in windows Spy it says:

>>>>>>>>>( Status Bar Text )<<<<<<<<

(1): Done

(2):

(3):

(4):

(5):

(6): Internet

Dos any one know how to set the script to look for (1) to be Done ??

Share this post


Link to post
Share on other sites

I move the mouse cursor to the top of the page,

and waits until it turns into a normal arrow.

Works 100 percent.

MouseMove(100, 1, 0)

$x = MouseGetCursor()

Do
$x = MouseGetCursor()
Sleep(500)
Until $x = 2

Share this post


Link to post
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

The PixelChecksum() function in the new unstable is also cool for things like that.

Share this post


Link to post
Share on other sites

Dos any one know how to set the script to look for (1) to be Done ??

I think StatusbarGetText ( "title" [, "text" [, part]] ) is what you're after :D

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

What do you mean by "it stops"?

Does the script pause? It shouldn't do that...

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

The script stops like if its done.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The script stops like if its done.

do you mean 'done', like it stops when the bottom of the page says "done"?

-Brett

Share this post


Link to post
Share on other sites

NO

It's just like the script expires.

Share this post


Link to post
Share on other sites

Put a MsgBox in your script after the loop checking for the page and see if it comes up.

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0