Sign in to follow this  
Followers 0
Shyke

Stripping _IELoadWait()

21 posts in this topic

For my script, I decided to strip down _IELoadWait() as I needed it with Refresh.

For $i = 1 To 25
    $oIE[$i].document.execCommand("refresh")
    Do
        Sleep(100)
    Until String($oIE[$i].document.readyState) = "complete" Or $oIE[$i].document.readyState = 4
Next

Well, my problem is that it goes into a never ending refresh spree... it doesn't even freeze up like you'd expect.

Suggestions?

Share this post


Link to post
Share on other sites



That tells me that the readyState already matches your conditions... try printing out readyState to the console and see what values you are finding.

Not sure why _IEAction($oIE, "refresh") isn't enough for you however -- it calls _IELoadWait() for you.

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

Share this post


Link to post
Share on other sites

It matches the condition when it's not even 100% loaded yet.

The refresh IE action isn't good enough for me because it takes up a crapload of lines and when you combine it with _IELoadWait(), it's insane. I'm trying to keep this program as minimalistic as possible.

Share this post


Link to post
Share on other sites

Busy?

Have not worked with this for a while..

Share this post


Link to post
Share on other sites

That failed to work too.

Share this post


Link to post
Share on other sites

There is a lot of code in _IELoadWait because it is a generalized routine to handle lots of different conditions and checks the readyState of more than just the document.

If your routine is returning before the item you are watching is ready, then I suggest you are not checking the readystate of the correct object. I suppose it is also possible that the readyState has not yet changed as a result of the refresh... in any case, some more debug statements are called for.

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

Share this post


Link to post
Share on other sites

_IEAction($oIE[$i], "refresh")

That gives me the same failure as the rest of them in the for loop.

Share this post


Link to post
Share on other sites

Can you provide a reproducer?


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

Share this post


Link to post
Share on other sites

A reproducer is stand-alone code. Make it so that I can simply execute what you give me, explain what happens and what you expect to happen and I'll be glad to help further.

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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Durr *slaps chest*

#include <IE.au3>
Opt("TrayMenuMode", 1)
Dim $oIE[99], $inet[99]
GUICreate("test", 390, 400, -1, -1, 0x00020000 + 0x10000000 + 0x00C00000 + 0x80000000 + 0x00080000)

$trayclose = TrayCreateItem("Close")
For $i = 1 To 25
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
    $oIE[$i].Navigate("http://www.google.com")
Next
For $i = 1 To 25
    _IEAction($oIE[$i], "refresh")
Next

GUISetState()
TraySetState()
Do
    $msg = GUIGetMsg()
    $traymsg = TrayGetMsg()
    If $msg = -3 Then Exit
    If $traymsg = $trayclose Then Exit
Until 0oÝ÷ Ø`¡ë(©îËh¦êÞ~·¬)à­©©j¨}Ú(@ÈM­jëh×6#include <IE.au3>
Opt("TrayMenuMode", 1)
Dim $oIE[99], $inet[99]
GUICreate("test", 390, 400, -1, -1, 0x00020000 + 0x10000000 + 0x00C00000 + 0x80000000 + 0x00080000)

$trayclose = TrayCreateItem("Close")
For $i = 1 To 25
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
    $oIE[$i].Navigate("http://www.google.com")
Next
For $i = 1 To 25
    $oIE[$i].document.execCommand("refresh")
Next

GUISetState()
TraySetState()
Do
    $msg = GUIGetMsg()
    $traymsg = TrayGetMsg()
    If $msg = -3 Then Exit
    If $traymsg = $trayclose Then Exit
Until 0

For some reason that works, it just doesn't wait until the page is 100% loaded.

Edited by Shyke

Share this post


Link to post
Share on other sites

In the first, I think all the extraneous flashing is caused by trying to refresh before the initial page loads finished. In the second, like the first, there is nothing that wait for the initial load to compete, nor the refresh.

The following code works will for me:

#include <IE.au3>
Opt("TrayMenuMode", 1)
Dim $oIE[99], $inet[99]
GUICreate("test", 390, 400, -1, -1, 0x00020000 + 0x10000000 + 0x00C00000 + 0x80000000 + 0x00080000)

$trayclose = TrayCreateItem("Close")
ConsoleWrite ("create: ")
For $i = 1 To 25
    ConsoleWrite ("." & $i)
    $oIE[$i] = ObjCreate("Shell.Explorer.2")
    $inet[$i] = GUICtrlCreateObj($oIE[$i], 20, 80, 350, 300)
;    $oIE[$i].Navigate("http://www.google.com")
    _IENavigate($oIE[$i], "http://www.google.com")
Next
ConsoleWrite (@CR & "refresh:")
For $i = 1 To 25
    ConsoleWrite ("." & $i)
    _IEAction($oIE[$i], "refresh")
Next
ConsoleWrite (@CR)

GUISetState()
TraySetState()
Do
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    If $msg = $trayclose Then Exit
Until 0

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

Share this post


Link to post
Share on other sites

Thank-you. After I modified the code a bit it worked.

Now, the new problem is the sleeps in LoadWait... it, as you would have guessed, makes my GUI and other functions unresponsive.

Suggestions?

Share this post


Link to post
Share on other sites

You can always use _IELoadWaitTimeOut to set the actual wait time to 0 and then manage it on your own. You can consider using ObjEvent to trigger based on the onreadystatechange event and you can avoid the use of the Sleep that _IELoadWait uses.

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

Share this post


Link to post
Share on other sites

You can always use _IELoadWaitTimeOut to set the actual wait time to 0 and then manage it on your own. You can consider using ObjEvent to trigger based on the onreadystatechange event and you can avoid the use of the Sleep that _IELoadWait uses.

Dale

I'm not sure how I'd go about using the ObjEvent to trigger.

Share this post


Link to post
Share on other sites

Sorry about the double post - I figured out what I need to get done.

I need to find a way to refresh 25 webpages, wait until they are fully loaded then run another function, all without using sleep.

Share this post


Link to post
Share on other sites

$oDoc = $oIE.document
$oEvt = ObjEvent($oDoc, "Evt_")

Func Evt_onreadystatechange()
    $o = @COM_EventObj
    if $o.readyState = "complete" then ;;;Stuff
EndFunc


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

Share this post


Link to post
Share on other sites

Could you explain to me in words what is happening there? I would like to understand the code that I use, while at the same time use it.

Share this post


Link to post
Share on other sites

When the document readystate changes, execute this function. Read about ObjEvent and look for examples in the forum if you haven't already.

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

Share this post


Link to post
Share on other sites

Thank-you for your help, you solved all of my problems.

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