Jump to content
Sign in to follow this  
van_renier

_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

 

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By triple_N
      Hi, community. Don't know where to debug anymore.
      Before this I received "Frame Notification Bar" listed when run
      Local $sClassList = WinGetClassList("[CLASS:IEFrame]") _writeLog("list CLASS: "&$sClassList ) But after a few time testing, the "Frame Notification Bar" does not listed anymore. Not sure why. Even though I have reverted the code to initial condition. I suspected because not closing IE properly. I have disable and enable back and restart the computer but not yet found back the class.
      My code: 
      if(StringInStr($oTd.innerText, $keyWord)<>0) Then Local $oElements = _IETagNameAllGetCollection($oTd) For $oElement In $oElements if(StringInStr($oElement.innerText, $keyWord)<>0) Then Local $status_click = _IEAction($oElement, "click") If ($status_click = 1) Then _writeLog("Action Success perform - click on selected link: "&$keyWord) Else _writeLog("failed perform Action Link") EndIf Return $status_click EndIf Next EndIf Any help needed.
      Result:
      Success to click Download
      list  CLASS: BrowserFrameGripperClass
      Client Caption
      WorkerW
      ReBarWindow32
      TravelBand
      ToolbarWindow32
      Address Band Root
      AddressDisplay Control
      Edit
      ToolbarWindow32
      ToolbarWindow32
      TabBandClass
      DirectUIHWND
      ControlBandClass
      ToolbarWindow32
      CommandBarClass
      ReBarWindow32
      Frame Tab
      TabWindowClass
      Shell DocObject View
      Internet Explorer_Server
      Version 3.5.4 
    • By HariKara
      I have a script that seems to launch perfectly fine with IECreate, however, I want to launch the Browser and a specific URL with the RunAs command. I fairly new to AutoIT and wanted to know if someone can point me in the right direction.
      Local $surl = "http://somewebsite.com/DODA/admin/job.aspx"
      Local $oIE = _IECreate($sURL)
      The above launches the website correctly with the correct URL, however, I have tried the below and this fails to load and browser?
      #include <AutoItConstants.au3>
      ;========================
      $oSleep = "200"
      Local $surl = "http://somewebsite.com/DODA/admin/job.aspx"
      Local $oIE = RunAs($args("username"), $args("domain"), $args("logonpassword"), "", "C:\Program Files (x86)\Internet Explorer\iexplore.exe http://somewebsite.com/DODA/admin/job.aspx")
      _IELoadWait($oIE)
       
      I get the following error back?
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidDataType
      --> IE.au3 T3.0-2 Error from function _IEGetObjById, $_IESTATUS_InvalidDataType
      --> IE.au3 T3.0-2 Error from function _IEGetObjById, $_IESTATUS_InvalidDataType
    • By WoodGrain
      Hi All,
      I've tried to create a script to browse to a web page in IE, but it only works for some sites, I've tried to simplify the script as much as possible, hoping you can point me in the right direction - thanks.
      This one going to Google does work:
      #include <IE.au3> $oIE = _IECreate("https://www.google.com.au/", 0, 1, 1) _IELoadWait($oIE) _IEQuit($oIE) But this one going to OneDrive opens the IE page, but fails immediately returning the errors, and the IE window is not closed:
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)
      --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidObjectType ()
      --> IE.au3 T3.0-2 Error from function _IEQuit, $_IESTATUS_InvalidObjectType
      #include <IE.au3> $oIE = _IECreate("https://abccorp-my.sharepoint.com/", 0, 1, 1) _IELoadWait($oIE) _IEQuit($oIE) Even if I put a sleep timer in for 10 seconds after the _IECreate it still doesn't work
      Thanks all!
    • By iamtech
      i tried to print ie windows with my default printer  using
      _IEAction ($oIE, "printdefault") but it was not working sometimes, autoit icon showing in tray but not printing anything.
    • By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.
       

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          GUISetBkColor(0x000000)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          GUISetState(@SW_SHOW)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
              Select
                  Case $UIfunc = $GUI_EVENT_CLOSE
                      _Exit()
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                      Else
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
                          Start()
                      EndIf
              EndSelect
          WEnd
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
              _IELoadWait($oIE)
              Again()
          ElseIf $loopTrick = 1 Then
              Sleep(3000)
              _IEAction($oIE, "refresh")
              Sleep(3000)
              Start()
          EndIf
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
          Start()
      EndFunc   ;==>Again
      Func _Exit()
          Exit
      EndFunc   ;==>_Exit
×
×
  • Create New...