Determining whether a page in IE11 is done loading

Get help with using AutoHotkey and its commands and hotkeys
DCombs
Posts: 2
Joined: 15 Jun 2016, 14:55

Determining whether a page in IE11 is done loading

15 Jun 2016, 16:02

Hello,

I'm new to using COM and i'm not sure what i'm reading on MSDN.

i'm trying to create a script that fills out forms through IE11.

but on my very first step, i need to wait for the page to finish loading, and the normal COM methods are ineffective.

Code: Select all

pwb := ComObjCreate("InternetExplorer.Application")
pwb.Visible:=true
pwb.Navigate("website")
while pwb.Busy or pwb.readyState != 4
           Sleep, 100
MsgBox, done loading

I'm unsure how or where to look to fix the error.
both Busy and readyState seem to not be functional on this particular page.

any ideas?


Here is the error i'm getting
---------------------------
Replacements.ahk
---------------------------
Error: 0x80004005 - Unspecified error

Source: (null)
Description: (null)
HelpFile: (null)
HelpContext: 0

Specifically: busy

Line#
001: pwb := ComObjCreate("InternetExplorer.Application")
002: pwb.visible:=true
003: pwb.Navigate("website")
---> 004: While,pwb.busy || pwb.ReadyState != 4
005: Sleep,100
006: Exit
007: Exit
007: Exit

Continue running the script?
---------------------------
Yes No
---------------------------
User avatar
jethrow
Posts: 188
Joined: 30 Sep 2013, 19:52
Location: Iowa

Re: Determining whether a page in IE11 is done loading

16 Jun 2016, 00:07

DCombs wrote:Here is the error i'm getting ... Specifically: busy
The error shows busy is causing an issue - have you tried without busy? If readystate alone doesn't work, you could watch for the DocumentComplete event, as shown in this post: https://autohotkey.com/board/topic/4705 ... -tutorial/

If none of that works, you could wait for the existence of a known element or content.

NOTE: the example you provided is working for my version of IE11 loading this webpage. If you don't provide an example that demonstrates the issue, no one can give you an exact answer.
DCombs
Posts: 2
Joined: 15 Jun 2016, 14:55

Re: Determining whether a page in IE11 is done loading

16 Jun 2016, 09:43

i'm seeing that busy and readystate works on most pages. however, at the specific page i'm at, i get that error when i use busy or readystate.

Unfortunately, i can't share this webpage because it's a development page for a company.


i'm not understanding how IE_DocumentComplete() works.

could you explain the code below?

Code: Select all

ComObjConnect(wb, "IE_")   ;// Connect the webbrowser object
loading := true            ;// Set the variable "loading" as TRUE
wb.Navigate("www.AutoHotkey.com")
while loading
   Sleep 10
MsgBox DONE!
ComObjConnect(wb)          ;// Disconnect the webbrowser object (or just wb := "")

IE_DocumentComplete() {    ;// "IE_" prefix corresponds to the 2nd param in ComObjConnect()
   global loading := false ;// Break the While-Loop
}

thanks for your response, i've been lost all day, and i can't figure out why busy or readystate don't work correctly on this page.

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 47 guests