Script freezes on IE input file popup using COM Object

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bodosko
Posts: 19
Joined: 05 May 2017, 10:49

Script freezes on IE input file popup using COM Object

05 May 2017, 10:59

Hello guys.
I'm using COM to fill some fields on a webpage but I encounter a problem while trying to fill an input file dialog.
After the script clicks the "choose file" button and the Choose file window opens, it completely freezes and will only unfreeze if I manually close the window.

Here is an example script to reproduce the problem:

Code: Select all

	ie	:= ComObjCreate( "InternetExplorer.Application" )
	ie.Navigate("https://www.cs.tut.fi/~jkorpela/forms/file.html")	;Just example webpage with input file
	ie.Visible := True

	While ( ie.Busy || ie.ReadyState != 4 )	; Waits for the webpage to finish loading
	Sleep 10

	ie.document.getElementsByName("datafile")[0].click()
	Sleep 1000 												; wait window open
	Send "file1.txt" "file2.txt"
	Send {ENTER}
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Script freezes on IE input file popup using COM Object

05 May 2017, 12:26

yes the COM object becomes owned by the Ahk script any msgbox that the IE process makes holds the script just as a normal msgbox that ahk makes it self
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
bodosko
Posts: 19
Joined: 05 May 2017, 10:49

Re: Script freezes on IE input file popup using COM Object

05 May 2017, 12:52

Is there any way of doing what I want without having to use two scripts?
bodosko
Posts: 19
Joined: 05 May 2017, 10:49

Re: Script freezes on IE input file popup using COM Object

05 May 2017, 13:39

I managed to make this work using ie.navigate instead of directly calling ie.document.

Code: Select all

ie.Navigate("javascript: document.getElementsById(""id"").click()")
Apparently this way the script won't freeze waiting for a return.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, jdfnnl, Joey5 and 218 guests