Jump to content
TXTechie

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

Share this post


Link to post
Share on other sites

@TXTechie

Look at _IEAttach to use an already existing instance of IE, and use the method .Navigate with the flag navOpenInNewTab to open the webpage in a new tab.

Post your script (as you already did) if you need further assistance :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


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

Share this post


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

Share this post


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

 

Share this post


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

Share this post


Link to post
Share on other sites

@TXTechie

Happy to have helped :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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

  • Similar Content

    • By moimon
      Hi all. 
      Sorry if my words are confusing because I am not good at English.
      I am writing code to embed website with Recaptcha in GUI. And then, the code will automatically press the "I'm not a robot" button. The problem here is:
         - The code still works fine when entering iFrame to interact with Recaptcha with the URL is "https://www.google.com/recaptcha/api2/demo"
      <snip>
       
         - But for other URLs (such as "https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php"), the code cannot be entered into the iframe.
       
      Code:
      <snip>  
      I did a lot of research but didn't know why.
       I sincerely thanks for the help. 
    • By SkysLastChance
      I am pretty sure the site that I am using was updated and now I am not seeing the same tags/elements that I used to. I tried using a UIAspy to see if I could grab them that way with no luck. 
      What do I need to do to be able to automate this again. Are the elements hidden somewhere?
      Instead of highlighting established account is highlights all of the web page almost. How can I get to the detail again? 
      I used to grab establish account by the name. Now I have nothing to even try to grab. 
      There are not elements in the event viewer either. 
       


       
      This is what happens when I try to inspect the element and click established account. 
      I get the same type of results in chrome
    • By yffulf
      Is there probably a way to click ie popup button and hide or invisible popup button in the same time?
      I try to use WinSetState @SW_hide ,
      the result is ie crashing or no response because button hide and the next click command won't work...
      $oForm=_IEFormGetObjByName($oIE,"form1") $obutton=_IEFormElementGetObjByName($oForm,"btn_OK") $hWnd = _IEPropertyGet($oIE, "hwnd") _IEAction($obutton,"focus") ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") WinWait("", "確定存檔嗎?") WinSetState("","確定存檔嗎?",@SW_Hide) ControlClick("", "確定存檔嗎?", "[CLASS:Button; TEXT:確定; Instance:1;]")  
    • By _leo_
      Hey there!
      I am having a problem with clicking a button in IE. As you can see in the code, there would be a class name to click it, but since this button exists several times with exactly the same code, I can only use the "Noch nicht veröffentlicht" to separate it from the others. But this part is just pure text without any classification. 
      "<div class="checkmark" data-v-1e5b1f70=""><svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 16 16" data-v-1e5b1f70=""><circle cx="8" cy="8" r="8" data-v-1e5b1f70="" /></svg></div>Noch nicht veröffentlicht"
      I was trying to click it with:
      #include <IE.au3> local $oNNVs = _IEFormGetCollection($oIE2) For $oNNV in $oNNVs If String($oNNV.innertext) = "Noch nicht veröffentlicht" Then _IEAction($oNNV, "click") EndIf Next and:
      $inputs = $oIE2.document.getElementsByTagName("div") For $input In $inputs If $input.innertext == "Noch nicht veröffentlicht" then $input.click() EndIf Next But nothing seems to work. Thanks for the help!
    • 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!
×
×
  • Create New...