Jump to content

readyState problems...


Recommended Posts

Well, here's my problem:

Variable must be of type "Object".:

If $oIE[$i].document.readyState = "complete" Then

If $oIE[$i].document^ ERROR

This error just started to occur today. $oIE[$i] equal to ObjCreate("Shell.Explorer.2") (_IECreateEmbeded).

So, who has any friggen clue what I'm supposed to do from here?

EDIT: Forgot to tell you guys what was going on...

For $i = 1 To 25
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
    $oIE[$i].Navigate ($site[$i])
Next

Do
    $master[50] = 0
    For $i = 1 To 25
        If $oIE[$i].document.readyState = "complete" Then
            $master[$i] = 1
        Else
            $master[$i] = 0
        EndIf
        $master[50] = $master[50] + $master[$i]
    Next
    If $master[50] = 25 Then
        MsgBox(0, "", "Success!")
        Exit
    EndIf
Until 0
Edited by Shyke
Link to comment
Share on other sites

My theory is that you are trying to get ReadyState before a Document exists. Try this:

#include <IE.au3>
For $i = 1 To 25
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
    $oIE[$i].Navigate ($site[$i])
Next

Do
    $master[50] = 0
    For $i = 1 To 25
        $oDoc = _IEDocGetObj ($oIE[$i])
        if $oDoc = 0 then
            $master[$i] = 0
        Else
            If $oDoc.readyState = "complete" Then
                $master[$i] = 1
            Else
                $master[$i] = 0
            EndIf
        EndIf
        $master[50] = $master[50] + $master[$i]
    Next
    If $master[50] = 25 Then
        MsgBox(0, "", "Success!")
        Exit
    EndIf
Until 0

Also, are you running this in SciTE? IE.au3 outputs COM errors to the console, so it would be useful to check that and see if you are getting a descriptive error message. I suspect it's a security related message. Are all the URLs in $site in the same Internet Zone? If not then you can have problems. IE might think it's an XSS security problem.

Also, I can see what you're doing - you're trying to create a tabbed web browser with embedded IE objects, are you not? This is possible, I have some prototypes lying about - however, this just doesn't work well, and I should know, I've beat my head against it for some time. Due to the architectures of AutoIt and the WebBrowser control, it's impossible to make all of the instances of the Control play nice with each other. Details here:

http://www.autoitscript.com/forum/index.php?showtopic=31539

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

It says it is an "IWebBrowser2".

I don't get this crash if I use:

For $i = 1 To 25
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
    $oIE[$i].Navigate ($site[$i])
Next
Sleep(3000)

Do
    $master[50] = 0
    For $i = 1 To 25
        If $oIE[$i].document.readyState = "complete" Then
            $master[$i] = 1
        Else
            $master[$i] = 0
        EndIf
        $master[50] = $master[50] + $master[$i]
    Next
    If $master[50] = 25 Then
        MsgBox(0, "", "Success!")
        Exit
    EndIf
Until 0

But having to sleep that extra three seconds sucks and it locks up my GUI.

EDIT: Nevermind, I figured it out. Thanks for the help.

Edited by Shyke
Link to comment
Share on other sites

_IELoadWait handles this sort of issue behind the scenes. It traps this COM error and assumes it is transient and retries until the document object is valid (or until the _IELoadWaitTimeOut value).

Dale

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

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