0
votes

I am running the following Autohotkey code that works all the time on good days and most of the time on bad days (slow internet and or computer).

079: Sleep,500
081: ie_win.document.all.lbContentIframe.contentWindow.document.all.btnOkId.click()  
082: Sleep,500
083: While,ie_win.document.all.lbContentIframe.contentWindow.document.readyState <> "complete"
084: Sleep,100

The error I am getting is for line 83

Description: Access is denied.

HelpFile: C:\Windows\System32\mshtml.hlp

Specifically: document

Is that because the lbContentIframe Iframe document isn't loaded yet? Previously I have tried

while !ie_win.document.getelementbyid("lbContentIframe") sleep, 100

and I haven't received any errors due to that line. Do I need to do that every time the Iframe might be refreshing before trying to check if it is done loading via the readyState property?

Also, once I get the above error it never starts working again no matter how many times I try. It is almost like the ie_win handle gets corrupted.

2

2 Answers

1
votes

Try

    While ie_win.readyState!=4 || ie_win.document.readyState!="complete" || ie_win.busy
1
votes

I've found that on several interactive web pages I would have to write a custom wait function based on a value I know will exist and be populated when the entire page is fully loaded.

Try Something like this:

ComObjError(false)
While (value == "") {
    value := ie_win.document.getElementsByClassname("YourElement")[1].innerText
    Sleep 100
    }
ComObjError(true)