Jump to content
Sign in to follow this  
Bam

_IENavigate()

Recommended Posts

Bam

Well what im trying to do is load acouple webpages with _IEnavigate(), it works but my problem is that some webpages like hang (or w/e the term is) resulting in _IEnavigate() with Wait = 1 can take along time for that page to load. So what I have done is made another script to read the status bar looking for the same text then refreshing the page.

Opt("WinTitleMatchMode", 2)

Local $LastStatusText, $Timeout = 0

While 1
    If $LastStatusText == ControlGetText ("Windows Internet Explorer", "", "[CLASS:msctls_statusbar32; INSTANCE:1]") Then
        If $LastStatusText <> "Done" Then
            If $LastStatusText <> "" Then
                $Timeout += 1
            EndIf
        EndIf
    Else
        $LastStatusText = ControlGetText ("Windows Internet Explorer", "", "[CLASS:msctls_statusbar32; INSTANCE:1]")
        $Timeout = 0
    EndIf
    If $Timeout > 50 Then
        Send("{f5}")
        $Timeout = 0
    EndIf
    Sleep(100)
WEnd

Problem is this isnt as reliable as I need it to be cause I ran into a webpage that gets stuck a loading 1 last thing that never finishes and it constanly refreshes the page. This isnt the first thing that I have tried but its been the most reliable so far.

I was wounder if any one had any suggestions / ideas.

Share this post


Link to post
Share on other sites
PsaltyDS

First of all, stop using $f_wait = 1, so you don't have to go to a separate script to monitor progress.

Once you do _IENavigate(), with $f_wait = 0, then go into a loop where you wait for a particular page element to load:

#include <IE.au3>

Global $sURL = "http://www.google.com/#hl=en&source=hp&q=AutoIt"
Global $oIE, $oStats

$oIE = _IECreate()
_IENavigate($oIE, $sURL, 0)
While 1
    If _IELoadWait($oIE, 10, 10) Then ExitLoop
    $oStats = _IEFormElementGetObjByName($oIE, "resultStats")
    If @error = 0 And IsObj($oStats) Then ExitLoop
WEnd
MsgBox(64, "Test", "Page is done.", 3)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Bam

Thx Psalty ;)

I cant beleive I didnt think of that :)

Nice google link to btw.

Edit:

uhh im not realy sure what this dose.

$oStats = _IEFormElementGetObjByName($oIE, "resultStats")

Edited by Bam

Share this post


Link to post
Share on other sites
SpinningCone

Thx Psalty ;)

I cant beleive I didnt think of that :)

Nice google link to btw.

Edit:

uhh im not realy sure what this dose.

$oStats = _IEFormElementGetObjByName($oIE, "resultStats")

just use IEloadwait with the timout option

http://www.autoitscript.com/autoit3/docs/libfunctions/_IELoadWait.htm

Share this post


Link to post
Share on other sites
PsaltyDS

uhh im not realy sure what this dose.

$oStats = _IEFormElementGetObjByName($oIE, "resultStats")

It gets the object reference to an element with a name (ID, actually) of "resultStats". While the page is not loaded yet, that function fails because that element doesn't exist yet. Once the page loads, that element exists and it retrieves a valid object reference. So this is how I am testing when the page is loaded. You would have to substitute a different element that applied to your target page.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Bam

I thought thats what I did but when I did a search looking for the element I couldn't find it but today I did.

But It seems to work great with what im trying to do. Thx again. :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.