document.getElementByID not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Michael8790

document.getElementByID not working

20 Aug 2018, 06:28

Dear AHK Team,

I can't make the document.getElementById command work.
At first it gave me an error saying the interface has not been detected (specifically document).
Now when I try to run the command below it gives the error: 0x80004005 - Unknown error
Specifically: document
Line 006
Continue running script y/n

Any idea what causes this issue?

Code: Select all

#SingleInstance, force

wb := ComObjCreate("InternetExplorer.Application") ; Create a IE instance
wb.Visible := True
wb.Navigate("https://www.google.com/?gws_rd=ssl")
wb.document.getElementById("lst-ib").value := "test"
return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: document.getElementByID not working

21 Aug 2018, 09:37

the webpage hasnt fully loaded yet and ure trying to access an element that doesnt exist yet. u need to wait until the page has fully loaded, before running the query
Michael8790

Re: document.getElementByID not working

21 Aug 2018, 11:32

Hi SwagFag,

Thank you for your reply.
Sorry yes I tried that as well with IE ready state 4.
I have just tried it again with a sleep, 20000 command but the issue is the same 20 seconds later.

Code: Select all

#SingleInstance, force

wb := ComObjCreate("InternetExplorer.Application") ; Create a IE instance
wb.Visible := True
wb.Navigate("https://www.google.com/?gws_rd=ssl")
sleep, 20000
wb.document.getElementById("lst-ib").value := "test"
return

It opens Google through IE but it always tells me that it can't access the document interace.
Can anyone else point me in the right direction?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: document.getElementByID not working

23 Aug 2018, 15:40

i cant reproduce the issue with IE11 on win10 running as admin. can u screenshot the error? what web browser does the call to comobjcreate open?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 249 guests