Jump to content

IE7 Tabbed browsing


AJP
 Share

Recommended Posts

Help...

IE7 Tabbed browsing question.

I have a script that checks to see if IE has a given page loaded, and inter act with that page.

_IEAttach Title or URL will find the page even if the page is not on the active IE tab. But I cant find a way to make that page become the active/top tab.

I have tried with no luck the Window Management functions. They wont see the loaded IE web page if it is not the active tab, as the window takes the title of the active tab.

Thanks

AP

Link to comment
Share on other sites

I wish I knew the answer to this, but I don't yet. MSDN has just started updating docs for scripting IE7 and if the method for bringing a tab forward is documented I haven't found it yet.

I am about to release a new IE.au3 beta to the forum for testing and using that you will be able to control tabs with the _IENavigate function, but I have not yet found methods of controlling existing tabs.

Dale

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

Link to comment
Share on other sites

  • 2 months later...

As of 2/12/07, there still seems to be no solution to this, at least in all the searching I did (unless Dale has found a solution?). The key quote I found was on an MS Forum post from 11/14/06: "...unfortunately there's no programmatic way for an extension to select a tab in IE7. IE does not yet expose a full-fledged tabbed browsing API set." Another post says: "To limit opportunities for malicious behavior, scripts running in tabbed windows cannot affect other tabs." That's good news for security reasons, but bad news for us who want to automate things.

Perhaps someone smarter than I could get AutoIt to figure out the coordinates of each tab in IE, programmatically move the mouse to the desired tab, and click it to activate it. I found another post with a possible solution that's horribly complicated and might not even work in Vista. Yet one more post talks about how to detect when the user changes tabs.

I will follow up with a link to some code with a workaround, albeit a clunky one.

Link to comment
Share on other sites

Looks like I cant post to Example Scripts since I have less than 10 posts, so Ill put the code here. Its a definitely a kluge, but hopefully is better than nothing. Basically, if it attaches to an existing browser session and the browser is IE v7 or above, it calls WinWaitActive with a two second timeout (could probably be less). If it times out, it assumes the desired tab is inactive. It gives the user the opportunity to switch to IE, click the desired tab, then switch back to the dialog box to click Retry. I told you it was clunky! I suppose another workaround would be to just open a new browser if it times out, but I dont want to keep opening new browsers. Hopefully someone will find this useful.

#include <IE.au3>
AutoItSetOption("WinTitleMatchMode", 2)
$strBrowserTitle = "Google"
$strURL = "http://www.google.com/"
$strIEversion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version Vector", "IE")

;Open new browser and navigate to web page, or find existing browser with that URL
$oIE = _IECreate($strURL, 1, 1, 0, 0)
If @extended Then
    ;Browser already existed, so switch to it
    If StringLeft($strIEversion, 1) < "7" Then
        WinActivate($strBrowserTitle)
        WinWaitActive($strBrowserTitle)
    Else
        ;Using IE v7 or higher.  Account for tab not being active.
        Do
            WinActivate($strBrowserTitle)
            ;Timeout after two seconds.  If the tab is not active, WinWaitActive will wait forever without a 
            ;timeout. This is a clunky workaround until someone finds a way to access inactive tabs in IE 7.  
            ;MS currently does not expose a full-fledged tabbed browsing API set.
            $strResult = WinWaitActive($strBrowserTitle, "", 2)
            If $strResult = 0 Then
                If MsgBox(5 + 48, "Tab Not Active", _
                        "The " & $strBrowserTitle & "website tab is not active.  Please switch" & Chr(13) & _
                        "to Internet Explorer, click the " & $strBrowserTitle & " tab, then" & Chr(13) & _
                        "switch back to this dialog and click Retry.") = 2 Then
                    ;User clicked Cancel
                    Exit ;Terminate script
                EndIf
            EndIf
        Until $strResult = 1
    EndIf
    ;Code to manipulate browser once active
EndIf
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...