Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

IE9 Protected Mode causes comobjcreate pointer to be invalid


  • Please log in to reply
9 replies to this topic
DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
Basically with IE9 Protected Mode turned on (which is default) the pointer created by comobjcreate is no longer valid after I navigate to a webpage with an HTTPS Url.

Here is what I want to do
1. Create ComObj
2. Navigate to a URL (HTTPS)
3. Login into webpage
4. Click on links in the new techportal page

It appears that between creating the com obj and navigating to a URL the pointer to the Web Browser object changes.
I know this because I can hide and unhide the com obj but as soon as I navigate to my techportal address I no longer can control this website with the old pointer. I have to find the new one. Which I suppose is okay, but I have multiple scripts to navigate this website that do alot of different things including navigating several pages deep.

I would like to be able to hide all the pages until the last page then make it visible with WB.Visible := true

The code can be run as is.
WB := ComObjCreate("InternetExplorer.Application")
WB.Visible := true 
MsgBox the com obj is visible. The pointer is good.
WB.Visible := false
MsgBox the com obj is invisible. The pointer is good

WB.Navigate("https://techportal.wwts.com/qxsweb/default.cfm")
While WB.Busy ;[color=red]I suspect the pointer here is invalid which means I have no way of knowing when the page is fully loaded[/color]
Sleep, 100 
MsgBox why is it visible again?`nIs it because the pointer is no longer valid?`n`nThis pretty much explains it all, I hope. With an invalid pointer I can do nothing with the webpage

/*
;The code below this comment section never works until I get the new pointer.
;I get the new pointer this way, which works perfectly, I can log in just fine.

For WB in ComObjCreate("Shell.Application").Windows    
 If InStr(WB.LocationName, "WWTS Extranet | Technician Portal")
  break
;With the new pointer I can hide/unhide, click on links and anything else I want

*/

MsgBox exitapp I added this so you can test the code
exitapp
iniread,PortalUsername,config.ini,credentials,PortalUsername
iniread,PortalPassword,config.ini,credentials,PortalPassword
WB.document.all.Login.value := PortalUsername
WB.document.all.Password.value := PortalPassword
WB.Document.all.80.click() 
 While WB.Busy                                                   
  Sleep, 100 
 WB.Navigate("https://techportal.wwts.com/qxsweb/emp/oneview_record.cfm")
  While WB.Busy                                                   
  Sleep, 100 
 WB.Visible := true
 MsgBox done

When I turn Protected Mode off then I can use the same pointer created by comobjcreate to navigate this webpage.

It appears when I navigate to an HTTPS the original window is closed and a new one is created with a new pointer.

As my code demonstrates I can get the new pointer, but I want to be able to navigate several pages deep before I make the window visible for the first time.

EDIT: 12:56PM 1/10/2012
I found that if I run the script as administrator it keeps the same pointer that was created by comobjcreate. That may be my only solution.


thanks
DataLife

[Moved from General Chat]
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Zod
  • Members
  • 214 posts
  • Last active: Jan 26 2012 08:02 PM
  • Joined: 06 Jul 2011
why would it be visible you made it invisible and it should remain so until you set visible to true
Posted Image Stolen from SKAN

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

why would it be visible you made it invisible and it should remain so until you set visible to true


Exactly my point. I made it invisible, then it becomes visible when I navigate to an HTTPS URL with this line.
WB.Navigate("https://techportal.wwts.com/qxsweb/default.cfm")

I have no control over the window using the original pointer. I have to run this code
For WB in ComObjCreate("Shell.Application").Windows    
 If InStr(WB.LocationName, "WWTS Extranet | Technician Portal") 
  break 
to get the new pointer. Then I can control the window by showing/hiding, clicking on links, whatever I need using the new pointer.

It appears IE security is closing the window created by comobjcreate thereby destroying the pointer and creating a new pointer when I navigate to the HTTPS URL.

Turning off Protected Mode or running the script as admin allows the original pointer to be used to control the webpage with the HTTPS URL. So in this case the original window created is not destroyed until I close it.

Maybe someone on the forum that is using IE9 with Protected Mode turned on can verify this for me.

thanks
DataLife
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008
I suspect something else than IE... I made a FaceBook script using IE9 and HTTPS and it's working fine, it even recieve the Send command to navigate on the page.

Navigate to an URL can't change the value of the property "Visible"...
The only solution is that when you "navigate" it's open an other window and doesn't navigate on the initial window.
Leave the window visible then try to add a "WB.Quit" after the "Navigate" and While WB.Busy :

WB := ComObjCreate("InternetExplorer.Application") 
WB.Visible := true
Sleep 100
WB.Visible := false
Sleep 100
WB.Visible := true
WB.Navigate("https://techportal.wwts.com/qxsweb/default.cfm") 
While WB.Busy
Sleep 100
WB.Quit


sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008

why would it be visible you made it invisible and it should remain so until you set visible to true


My guess is it's not the same window.

Zod
  • Members
  • 214 posts
  • Last active: Jan 26 2012 08:02 PM
  • Joined: 06 Jul 2011

My guess is it's not the same window.

Would seem so based on the later post by OP. I deplore IE9 and refuse to use it. as much as i need IE for automation i have begun exploring automation via MSAA or winhttp. I think my days of interacting with the browser are nearing the end. Good job Microsoft you have finally put a sour taste in even my mouth. IE breaks all sorts of content that even worked in older versions. I mostly use Chrome outside the workplace. That said

If the pointer is destroyed it is most likely the windows is closed and a new one is created. might look at employing NewWindow3
Posted Image Stolen from SKAN

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

I suspect something else than IE... I made a FaceBook script using IE9 and HTTPS and it's working fine, it even recieve the Send command to navigate on the page.

Navigate to an URL can't change the value of the property "Visible"...
The only solution is that when you "navigate" it's open an other window and doesn't navigate on the initial window.
Leave the window visible then try to add a "WB.Quit" after the "Navigate" and While WB.Busy :

WB := ComObjCreate("InternetExplorer.Application") 
WB.Visible := true
Sleep 100
WB.Visible := false
Sleep 100
WB.Visible := true
WB.Navigate("https://techportal.wwts.com/qxsweb/default.cfm") 
While WB.Busy
Sleep 100
WB.Quit

I put WB.quit after the While WB.Busy and I get this error.
-----------------------------------------------------------------------
Error: 0x800706B5 - The interface is unknown
-----------------------------------------------------------------------

Then I put WB.Visible:=false after While WB.Busy to see if I could hide the window and I got this error.
-----------------------------------------------------------------------
Error: 0x80010108 - The object invoked has disconnected from its clients
----------------------------------------------------------------------

Seems obvious to me the original window is being destroyed and a new one is being opened with a new pointer.

I can run the script as an administrator and everything works as it should.

That can be my solution for this script, but for other scripts that I wish to distribute to other people running as an administrator is not received very well.

Thanks Zod for the link to NewWindow3, that seems to be over my head. I don't understand what NewWindow3 would be doing in my script.

This line ....
"An interface pointer that, optionally, receives the IDispatch interface pointer of a new WebBrowser object or an InternetExplorer object."

sounds like my original interface pointer will receive the pointer of a new window.

If thats true then it may work for this issue. I just have no idea how to implement it.

DataLife
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
Your new webbrowser object should be in the ppDisp param. This thread should give you some ideas: Com Events - Using ByRef Parms

DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
UPDATE:

I turned off UAC and all my problems have gone away.

In addition to this problem, any of my scripts that used a hotkey on internet explorer would not work.

I have a 3 line script that sends Ctrl-W to IE to close tabs. I put this script on my taskbar and with one click I can close the currently open tab. I know I can close the tab with one click on the tabs above the webpage but sometimes trying to determine exactly which tab is lighter in color then the others takes me looking at all the tabs a couple of times. So with a simple click on the taskbar I close the open tab.

That script quit working unless ran as administrator or with UAC turned off.

I have another script that sends a right click to open the right click menu in IE9, that right click would not work unless ran as administrator or with UAC turned off.

I wrote some of these scripts with UAC turned on.

Anyone have any idea what changed to cause IE9 to not work with my hotkeys anymore?

thanks
DataLife
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Thermopyle
  • Members
  • 135 posts
  • Last active: Apr 04 2012 04:04 PM
  • Joined: 27 Jul 2011
I'm running into the same problem as TC with one of my scripts. I've used a modified version of the pointer reassignment script, like so:
pwb.visible := false

pwb.Navigate(url)



For pwb in ComObjCreate("Shell.Application").Windows    

    If InStr(pwb.LocationURL, url) 

      break 

pwb.visible := false
This works, but the window does flash briefly on the screen. I'm guessing this is due to the delay between Windows recreating the Window and the script recreating the pointer and re-setting the visibility to false. Is there any way to resolve this flash, or is this just the price of using Windows 7?