Jump to content

_IE functions, losing reference to object variable of an InternetExplorer.Application object


Recommended Posts

Could someone help me understand why I'm losing the object for certain _IE  user-functions (those included with Au3 v3.3.10.2)

#include <IE.au3>   ; Required for automatically entering login credentials to app manager
GLOBAL $oIE
$oIE = _IECreate("about:blank", 1)
; _IEQuit ($oIE)   ; _IEQuit line HERE, it work, closing the browser...
ConsoleWrite ("===============================" & @CRLF )
If WinExists ( "Blank Page - Windows Internet Explorer") <> 1 then
   While WinExists ("Blank Page - Windows Internet Explorer") <> 1
      sleep ( 500 )
   WEnd
EndIf
sleep ( 1200 )
ConsoleWrite ("===============================" & @CRLF )
; _IEQuit ($oIE)   ; _IEQuit line HERE, it work, closing the browser...
ConsoleWrite ('This is where the object, $oIE, gets broken/lost' & @CRLF )
   _IENavigate( $oIE, "http://www.msn.com" )
   sleep (3000)
ConsoleWrite ("===============================" & @CRLF )
sleep ( 5000 )
_IEQuit ($oIE) ; HERE FAILS, console error: "--> IE.au3 T3.0-1 Error from function _IEQuit, $_IEStatus_InvalidObjectType"
exit

In the above script, there are 3 lines with _IEQuit. The 1st 2 are commented out, but they work with closing the browser fine, but the 3rd line, fails to close out the browser window.

(I'm not wanting to close out the browser window, but I was trying to figure out why subsequent calls lose the object variable reference of $oIE. Using _IEQuit seemed to be the easiest way to ensure we were attached to the same browser window.

I've also noticed that using the above script, after the script exits (with the 3rd _IEQuit line intact), since the browser window is still open, if I try and enter any URL into the adress bar, pressing enter then causing a new browser window to open up.

Any suggestions on why the object reference is getting broken?

Thanks,

Van

 

Link to comment
Share on other sites

Tried running the script you posted, and it worked like it should, here is the console output:

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IEStatus_NoMatch
===============================
===============================
This is where the object, $oIE, gets broken/lost
===============================
+>15:24:18 AutoIt3.exe ended.rc:0
+>15:24:18 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 14.827

 

The issue you are referring to (pressing enter then causing a new browser window to open up.) might be caused by IE itself, not AutoIt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...