Interacting with IE with COM Interface and Java Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Interacting with IE with COM Interface and Java Script

30 Sep 2019, 04:36

Why i asked for all your code was that in one of your images you had sleep between the navigate and the element interaction but in your 4 lines of code you do not

after a navigate event you have to wait for the document your navigating to load before trying to interact with any elements on the new document

so your 4 lines have at least that issue...

Code: Select all

ie := ComObjCreate(("InternetExplorer.Application"))
ie.Visible:=True
ie.Navigate("https://xxxx/xxxx/man.htm")
while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy)
	sleep 100
; or simply use a hard coded sleep of 5000 if you always know that 5 seconds is what it takes
ie.document.frames["application"].getElementById("USERNAME.DUMMY.DUMMY").value := "Mary"
also the frame element will most likely have it own .document

Code: Select all

ie.document.parentWindow.frames["application"].document.
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
aircooled
Posts: 80
Joined: 01 Dec 2018, 08:51

Re: Interacting with IE with COM Interface and Java Script

01 Oct 2019, 05:10

Blackholyman wrote:
30 Sep 2019, 04:36
Why i asked for all your code was that in one of your images you had sleep between the navigate and the element interaction but in your 4 lines of code you do not

after a navigate event you have to wait for the document your navigating to load before trying to interact with any elements on the new document

so your 4 lines have at least that issue...

Code: Select all

ie := ComObjCreate(("InternetExplorer.Application"))
ie.Visible:=True
ie.Navigate("https://xxxx/xxxx/man.htm")
while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy)
	sleep 100
; or simply use a hard coded sleep of 5000 if you always know that 5 seconds is what it takes
ie.document.frames["application"].getElementById("USERNAME.DUMMY.DUMMY").value := "Mary"
also the frame element will most likely have it own .document

Code: Select all

ie.document.parentWindow.frames["application"].document.
You are right I didn't put the Delay's but I had a lot and experimented with long waiting times, the problem was not that see below. Thanks anyway.
aircooled
Posts: 80
Joined: 01 Dec 2018, 08:51

Re: Interacting with IE with COM Interface and Java Script

01 Oct 2019, 05:13

As gregster pointed out this solved the problem:

ie.document.getElementById("application").contentDocument.getElementById("USERNAME.DUMMY.DUMMY").value := "Mary" :bravo: :superhappy:
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Interacting with IE with COM Interface and Java Script

01 Oct 2019, 05:48

What part of what i said was not part of fixing your issue?

You can not interact with the element without waiting -> not doing so will make your code fail

You need to act on the frame’s document -> in your case .contentDocument worked

But great you made it work...
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: JnLlnd, Mycroft-47, Rohwedder and 142 guests