Jump to content

How to use an open IE window and then open a new IE tab?


Recommended Posts

Hello Everyone,

I'm looking for a way to use an already open Internet Explorer (IE) window (if one is up and running) and then navigate to a new URL in a new IE tab.

I thought that _IECreate would easily meet my needs. However, when I use the following script:

#include <IE.au3>

Local $oIE = _IECreate("https://" & $Server & ":8444/", 1, 1, 0, 1)

...with one or more open IE windows, it still opens yet a new IE window.

Are there any other ideas for how to reliably use an already open IE windows and then how to open a new tab in IE to navigate to a new URL?

Regards,

TX Techie

Link to comment
Share on other sites

@FrancescoDiMuro

Thank you for your assistance.

I guess I should have stated that I haven't had any luck with _IEAttach either. Here's my code:

#include <IE.au3>

Const $navOpenInNewWindow = 1
Const $navOpenInNewTab = 2048
Const $navOpenInBackgroundTab = 4096
Const $navOpenNewForegroundTab = 65536
Const $sPrimaryServer = "server"

Local $oIE = _IEAttach("", "instance")
$oIE.Navigate("https://" & $sPrimaryServer & "/", $navOpenInNewTab)

And I receive the following error:

Quote

--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
"C:\Users\TXTechi\Desktop\Test.au3" (11) : ==> Variable must be of type "Object".:
$oIE.Navigate("https://" & $sPrimaryServer & "/", $navOpenInNewTab)
$oIE^ ERROR

What am I doing wrong?

Edited by TXTechie
Link to comment
Share on other sites

In fact, NONE of the _IEAttach examples from the AutoIt Help file work on my PC - they all throw the same "--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch" error!

I'm running a fully patched Windows 10, 64-bit (release 1809) PC.

What's going on?

Link to comment
Share on other sites

It usually means there is no instance of IE running.  But if you get the error with the examples...What version of autoit are you using ? 

Have you checked if you can get the handle of the running IE Window ?

 

 

Link to comment
Share on other sites

I'm using the latest release version of AutoIt (3.3.14.5) and I can successfully get a Window handle for my open IE window using WinList:

#include <IE.au3>

Const $navOpenInNewWindow = 1
Const $navOpenInNewTab = 2048
Const $navOpenInBackgroundTab = 4096
Const $navOpenNewForegroundTab = 65536
Const $sPrimaryServer = "server"

; Retrieve a list of window handles.
Local $aList = WinList()

; Loop through the array displaying only visable windows with a title.
For $i = 1 To $aList[0][0]
    If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
        If StringInStr($aList[$i][0], "Internet Explorer") > 0 Then
            ConsoleWrite("Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1] & @CRLF)
            Local $oIE = _IEAttach($aList[$i][1], "hwnd")
            $oIE.Navigate2("https://" & $sPrimaryServer & ":8444/", $navOpenInNewTab)
        EndIf
    EndIf
Next

But, when I pass the handle from WinList into _IEAttach, I get the same "--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch" error!:

Quote

Title: Calabrio ONE - Internet Explorer
Handle: 0x000A0D82
--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
"C:\Users\TXTechie\Desktop\NewTest.au3" (22) : ==> Variable must be of type "Object".:
$oIE.Navigate("https://" & $sPrimaryServer & "/", $navOpenInNewTab)
$oIE^ ERROR
->14:15:14 AutoIt3.exe ended.rc:1

 

Link to comment
Share on other sites

Wow! This is crazy! I must have something weird going on with my primary (and AutoIt developer) PC!

I compiled one of my scripts that use _IEAttach and copied it to my 2 test PCs (1 = Win10 and 1 = Win7) and it worked fine on both!

Sounds like it's time to "refresh" my primary PC. What a pain! 😥

@FrancescoDiMuro & @Nine - I want to thank you both, very much, for your assistance (and patience)!

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...