Jump to content
Sign in to follow this  

IE7 / IE8 Problem with Tabs

Recommended Posts


What I am looking for is a secure way to get the currently selected tab in an IE-Browser. I've searched the forum for several hours but could find a satisfying solution.

I tried checking for the active tab with WinGetState but it didn't work, because all my tabs have the same title and it returns the state of the first tab. Then I tried to set the titles of the tabs so that they are unique, witch brought me to believe WinGetState is useless on IE-Tabs because I always got a 7 form WinGetState.

Func _active_tab()
    $o_Shell = ObjCreate("Shell.Application")
    $ies = $o_Shell.Windows(); collection of all ShellWindows (IE and File Explorer)
    $count = 1
    For $oBrowser In $ies
        If _IEPropertyGet($oBrowser, "title") = "" Then ContinueLoop;my tabss do have a title
        $oBrowser.document.title = $count
        If BitAND(WinGetState($count), 8) <> 0 Then 
            MsgBox(0,$count, WinGetState($count) & @LF & _IEPropertyGet($oBrowser, "locationurl"))
            Return $oBrowser
        $count += 1

Share this post

Link to post
Share on other sites

IE works hard to hide the fact that a browser instance is in a tab (presumably for security reasons). In many cases you may be able to compare the windowtitle to the title since the windowtitle typically changes and includes the active document title at the beginning of the string.


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post

Link to post
Share on other sites

Thx. At least I know now that this is an unwanted feature. To look for a certain title won't help, because in my case the windows/tabs realy do have the same. And even if not. What I tried to create are Buttons which navigate to certain pages in the active tab almost like bookmarks. Well, I guess I can stop working on this particular project then.

Edited by magnifier512

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