IE automation after Windows 10 upgrade Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

IE automation after Windows 10 upgrade

Post by kczx3 » 30 Sep 2016, 08:18

Hi all,

Some code that has been working flawlessly on Windows 7 with IE 11 has stopped working since upgrading to Windows 10 Enterprise edition at my office. I have two such examples but will start with just one for now.

I have a listview that gets populated with tickets from our help desk database. I have the rows grouped by the queue that they are in using the native listview group-view. I have added a link to the group header, again using native functionality. When the link is clicked, all the tickets in the group are to be opened in a single IE instance on different tabs. The following is the function I use to open the group of tickets:

Code: Select all

massOpen(hwnd, gID) {
	Global iePID
	Gui, Listview, %hwnd%
	Process, Exist, iePID
	If !ErrorLevel {
		IE := ComObjCreate("InternetExplorer.Application")
		WinGet, iePID, PID, % "ahk_id " . IE.HWND
	}
	Loop, % LV_GetCount() {
		if(LV_EX_GetGroup(hwnd, A_Index) = gID)	{
			LV_GetText(ticketSessionID, A_Index, 3)
			if !IE.Visible	{
				IE.Navigate(preURL . ticketSessionID)
				IE.Visible := True
			}
			else
				IE.Navigate(preURL . ticketSessionID, 2048)
			sleep, 1000
		}
	}
}
The code works for the first ticket, opening it in IE without the 2048 flag to open in a new tab. The problem is when it gets to the next ticket that is in that group and it checks for IE.Visible. I get the following error:
Image

If I click yes, I get several errors for each subsequent URL that I try to open on both the IE.Visible check and the IE.Navigate() method. They all say, "The interface is unknown." or "The RPC server is unavailable."
Image
Image

Hoping someone has some thoughts on this...

I will note that the following test script seems to work fine with a sleep between the navigations:

Code: Select all

IE := ComObjCreate("InternetExplorer.Application")
IE.Visible := True
IE.Navigate("http://www.google.com")
while ie.ReadyState != 4
	sleep 50
IE.Navigate("https://www.helpdesk.mhc.net", 2048)
IE := ""

ExitApp
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: IE automation after Windows 10 upgrade  Topic is solved

Post by kczx3 » 30 Sep 2016, 10:37

I solved this myself. Forgot about the weirdness beginning with Windows 8 and needing to run the scripts as admin. I included RunAsAdmin.ahk as an #Include file and that fixes the issues.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: IE automation after Windows 10 upgrade

Post by Capn Odin » 30 Sep 2016, 12:14

I thought about suggesting that, but I feel unhelpful when I suggest someone run their script with administrator privileges. Too me it is akin to asking someone to restart their router.

In regards to your script, if the function is called a second time and a process with the pID iePID exist then the variable IE will be emty, or am I missing something ?
Please excuse my spelling I am dyslexic.
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: IE automation after Windows 10 upgrade

Post by kczx3 » 30 Sep 2016, 12:56

Well, the reason I did that was to try and track whether or not the user had closed the window that IE pointed to. So when I create an IE instance, I get its PID via IE.HWND and then use that globally to track whether that particular instance is open or not. I'm pretty sure that I tried using If WinExist("ahk_id " IE.HWND), but it didn't seem to be working for me. So basically in my function above, if the process with PID = iePID exists, then use that reference of IE to open the tickets within. Otherwise, create a new instance of IE in that same IE var, and proceed with opening the tickets in that new window. The idea was to limit everything to a single IE instance.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: IE automation after Windows 10 upgrade

Post by Capn Odin » 30 Sep 2016, 13:11

But in that case wouldn't you need to make the variable IE global or static ?
Please excuse my spelling I am dyslexic.
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: IE automation after Windows 10 upgrade

Post by kczx3 » 30 Sep 2016, 13:22

Capn Odin wrote:But in that case wouldn't you need to make the variable IE global or static ?
Touche. I added IE to be global.
User avatar
kczx3
Posts: 1649
Joined: 06 Oct 2015, 21:39

Re: IE automation after Windows 10 upgrade

Post by kczx3 » 14 Aug 2017, 08:32

Just wanted to update this. I found out that the actual problem has to do with my work's intranet sites and running in compatibility mode. I referenced this post and using the InternetExplorerMedium COM object fixed the issue and now I can run my script without admin privileges which is ultimately what I wanted.
User avatar
adegard
Posts: 90
Joined: 24 Nov 2017, 05:58
Contact:

Re: IE automation after Windows 10 upgrade

Post by adegard » 21 Nov 2018, 06:50

This topic is old... but I create some functions to simplify IE automantion: https://autohotkey.com/boards/viewtopic ... 27#p249027
Could be usefull for someone
Post Reply

Return to “Ask for Help (v1)”