none
IE7 Tabs RRS feed

  • Question

  • I am looking for a way using the SendMessage API or something along those lines to activate a different Tab from an external application, so I can detect if a URL is already open and restore that instance of IE and automatically switch to the proper tab.
    Thursday, September 7, 2006 5:35 AM

Answers

  • Hi Michael,

    There are not specific APIs for automating tabs in IE7. You can you accessibility APIs to activate different tabs. We are looking at this area for future development and it would help to understand exactly what you'd liek to see here.

    Thanks
    -Dave  

    Monday, September 11, 2006 4:51 PM

All replies

  • Hi Michael,

    There are not specific APIs for automating tabs in IE7. You can you accessibility APIs to activate different tabs. We are looking at this area for future development and it would help to understand exactly what you'd liek to see here.

    Thanks
    -Dave  

    Monday, September 11, 2006 4:51 PM
  • What I would like to see is the ability to list all open tab URLS and page titles, and the ability to activate the different tabs.  Even if it is not coded directly as an API just information on what is the best way to do this.  Currently I am developing an add on application to a product my company sells that opens the users current instance of IE if they are on the correct page or launches a new one if they are not.  Currently I list all windows in the thread of IEXPLORE and if the window does not contain the title I am looking for then I enumerate its children, if I find the match there I will open that instance of IE but I can not change the tab for the user they must click that themselves.  When I am able to bring that active Explorer up but it causes problems within IE itselfs because it does not have that as being the active tab so you are unable to click on anything you see on the page. Any help on activating a different tab as a quick fix would be of great help.
    Monday, September 18, 2006 3:12 PM
  • I also want to know how to switch to the specified tab in IE7 without clicking action.
    Tuesday, October 24, 2006 8:28 AM
  • How can you count the number of tabs open?
    Thursday, October 26, 2006 7:56 PM
  • I want to activate the tab as well.

    I am printing document , it works fine with IE 6 but when it comes to IE 7 it prints all tabbed windows open in my current IE instance.

    What I want is , I want to print only currently active TAB.

    Please help me.

    Tuesday, November 14, 2006 4:46 PM
  • Hi, the SPYXX utility (VS.net>Tools menu) lists the windows heiarchy under the top container (in IE7's case classname="IEFrame") under which are the windows with a classname of TabWindowClass, so to count the number of open tabs enum the windows under the top IEFrame window and count those with a classname of TabWindowClass.

    You should be able to use the same method to locate and activate a non-active tab, though I have not tried this method myself... maybe the SendMessage api (though there are no documented WM values for show tab) or maybe the ShowWindow api.

    Regards.

    Wednesday, November 22, 2006 4:14 AM
  • I have the exact same problem!

    I can get the last opened TAB, but that doesn't help me much:(

    I'll subscribe to this post to see if you get a solution.. I hope!

    Thursday, January 11, 2007 8:40 AM
  • I would like to see a way to save a TAB GROUP and then go to Favorites->TAB GROUPS->my group and reopen all the tabs that I had saved in that group (I watch several codeplex projects of mine as well as several msdn forums, when my son reboots because his game crashes I have to manually open all those sites again:(

     

    Tuesday, January 16, 2007 10:42 PM
  • Clyde,

    I thought that was a good idea...so I spent the day writing a band object that launched tab groups from favorites.

    Then I looked in IE 7 favorites...it already has this feature! lol.

    Friday, January 19, 2007 1:00 AM
  • Hi CableHead,

    If you are looking for a job, I am afraid that I can't offer you one... hell I need one too.

    What I would like to proposition you with though is a combined effort to write a BHO for IE6 and IE7 in C++ or ATL. It would require a moderate skills level in either one of these languages and also some API and Callback usage.I already have an established customer base and a web site http://www.iecustomizer.com and could offer you a cut of the sales in return for your efforts. This may turn out to be a practicle use of your idle time.

    Initially please go to http://www.iecustomizer.com/?url=contact.asp and send us your contact details (email, Messenger ID, ICQ or Yahoo Messenger ID's) so that we can establish a dialog.

    Regards.

    Friday, January 19, 2007 10:18 AM
  • I used the feature in favorites to add a tab group to my favorites, but I see no way to open a tab goup.  That is, open all tabs in a group (that was saved in favoties) at once with one click of a menu item.
    Friday, January 19, 2007 1:18 PM
  • IECUST...

    Would have to be C#.

    Friday, January 19, 2007 1:40 PM
  • Clyde...

    Wow...your right. Looks like I'll finish it then. One click is the only way to go.

    Friday, January 19, 2007 1:43 PM
  • COOL :) !
    Friday, January 19, 2007 9:39 PM
  • Hi Clyde,

    All you have to do is click on the arrow that appears towards the right of your folder's name when you hover over it with your mouse. That will open all the bookmarks contained in the folder in different tabs.

    Regards,

    Mauricio

    Friday, January 19, 2007 10:19 PM
  • I have IE version 7.0.5730.11 and clicking on the arrow to the right of the tab group name in favorites does not open anything but the menu item list showing the links to the web sites that I saved as a group.  It doesn't open any tabs at all :(.  I must be missing something.
    Saturday, January 20, 2007 5:48 AM
  • Cablehead,  did you ever get it working?
    Monday, January 29, 2007 6:33 AM
  • Clyde...yes I do have a working version. Now working on a way to close all open tabs before navigating to another "group".
    Monday, January 29, 2007 10:29 AM
  • I look forward to it, cablehead :) 

    It's a drag opening up 7 or 8 tabs to get to my codeplex projects and the msdn forums that I watch.

    Tuesday, February 6, 2007 6:12 PM
  • Clyde...if your tired of clicking...send me a mail yaylindsay@hotmail.com if you would like to check it out.
    Wednesday, February 7, 2007 2:56 AM
  • Create internet shortcuts to all of your favorite forums and feeds and place them into a folder in your Favorites. When you hover your mouse over the folder, an arrow to the right side will come up. If you click on this arrow all the links inside the folder will open in separate tabs. You can also right click on the folder and select "Open in Tab Group"
    Wednesday, February 14, 2007 12:26 AM
  • Hi,

    I just found solution. Spicific IE7 tab can be set as active via Active Accessability !

    This is my very very first experemental but !!!WORKING!!! code !
    I write it under BDS 2006, but it's must work under Visual studio to.

    I hope it's helps:

    void __fastcall TForm1::ActivateTab(TObject *Sender)
    {
    HRESULT hRes;
    HWND MainIEWnd;
    HWND CommandBarWnd;
    HWND ReBarWnd;
    HWND TabBandWnd;
    HWND DirectUIWnd;
    BSTR tabCaption;
    long TabsCount=0,TabsReceived=0,newRes;
    IAccessible *tabsAccess,*tabObject,*newObj;
    IDispatch *tabDisp,*tab1;
    VARIANT ChildStruct[10],tabStruct[10],tabQueryStruct,tabResStruct;
    tabQueryStruct.vt=VT_I4;
    tabQueryStruct.lVal=CHILDID_SELF;
    /*
    IE7 windows tree:

    IEFrame
       |
       --CommandBarClass
            |
            --ReBarWindow32
               |
               --TabBandClass
                  |
                  --DirectUIHWND   <<<<< IE 7 Tabs here !!!
    */

    MainIEWnd=FindWindow("IEFrame",NULL);
    if(!MainIEWnd)
        {
        ShowMessage("DEBUG: Unable to find main IE window");
        return;
        }
    CommandBarWnd=FindWindowEx(MainIEWnd,NULL,"CommandBarClass",NULL);
    if(!CommandBarWnd)
        {
        ShowMessage("DEBUG: Unable to find CommandBarWindow");
        return;
        }
    ReBarWnd=FindWindowEx(CommandBarWnd,NULL,"ReBarWindow32",NULL);
    if(!ReBarWnd)
        {
        ShowMessage("DEBUG: Unable to find ReBarWindow32");
        return;
        }
    TabBandWnd=FindWindowEx(ReBarWnd,NULL,"TabBandClass",NULL);
    if(!TabBandWnd)
        {
        ShowMessage("DEBUG: Unable to find TabBandClass");
        return;
        }
    DirectUIWnd=FindWindowEx(TabBandWnd,NULL,"DirectUIHWND",NULL);
    if(!DirectUIWnd)
        {
        ShowMessage("DEBUG: Unable to find DirectUIHWND");
        return;
        }
    if(AccessibleObjectFromWindow(DirectUIWnd,OBJID_CLIENT,IID_IAccessible,(void **)&tabsAccess)!=S_OK)
        {
        ShowMessage("DEBUG: Unable to get IAccessible interface");
        return;
        }
    hRes=tabsAccess->get_accChildCount(&TabsCount); // get objects count
    if(!SUCCEEDED(hRes))
        {
        ShowMessage("DEBUG: Unable to get Objects count");
        return;
        }
    hRes=AccessibleChildren(tabsAccess,0,TabsCount,ChildStruct,&TabsReceived);
    if(!SUCCEEDED(hRes))
        {
        ShowMessage("DEBUG: Unable to get objects");
        return;
        }
    for(int i=0;i<TabsReceived;i++) // enum objects
        {
        if(ChildStructIdea.vt==VT_DISPATCH)
            {
            tabDisp=ChildStructIdea.pdispVal;
            hRes=tabDisp->QueryInterface(IID_IAccessible,(void **)&tabObject);
            if(!SUCCEEDED(hRes))
                {
                ShowMessage("DEBUG: QueryInterface to tabObject failed");
                continue;
                }
            hRes=tabObject->get_accRole(tabQueryStruct,&tabResStruct);
            if(!SUCCEEDED(hRes))
                {
                ShowMessage("DEBUG: Unable to receive object role");
                continue;
                }
            if(tabResStruct.lVal!=ROLE_SYSTEM_PAGETABLIST)  // we need only PageControl ! skip
                continue;                               // another contorls
            tabsAccess=tabObject; // we found PageControl with IE7 tabs !
            hRes=tabsAccess->get_accChildCount(&TabsCount);  // number of opened tabs + New Tab button
                    if(!SUCCEEDED(hRes))
                {
                ShowMessage("DEBUG: tab count failed");
                continue;
                }
            hRes=AccessibleChildren(tabsAccess,0,TabsCount,tabStruct,&newRes);
            for(int j=0;j<newRes;j++)   // enum tabs
                {
                tab1=tabStruct[j].pdispVal;
                hRes=tab1->QueryInterface(IID_IAccessible,(void **)&newObj);
                if(!SUCCEEDED(hRes))
                    {
                    ShowMessage("DEBUG: QueryInterface to newObj failed");
                    continue;
                    }
                 hRes=newObj->get_accName(tabQueryStruct,&tabCaption);
                 if(!SUCCEEDED(hRes))
                    {
                    ShowMessage("DEBUG: Unable to receive tab caption");
                    continue;
                    }
                if(tabCaption==L"your specific string")
                                    // make this f..g tab active !!!!
                    newObj->accDoDefaultAction(tabQueryStruct);
                }
            }
        }
    }
    //---------------------------------------------------------------------------
    • Proposed as answer by nayR_Inverted Saturday, August 9, 2014 9:26 PM
    Wednesday, February 14, 2007 8:24 PM
  • Anyone get Amsdev code working in C#?
    Friday, February 23, 2007 8:16 PM
  •  Amsdev!!   ((you are now my best friend !!  :) ))
    thanks a lot, i was looking for 'IE 7 tabs management' for months.

    well, i did translate your C code in VB (level VB5.00), thanks to the help of another sharer on a 'technical PC  forum'.

    with 'my' version, I have seen that in fact i only walk thru the tabs displayed on screen (what i call level 4 = the children of object number 7),
    case when much tabs are opened than the number of tab buttons that can be displayed on the IE7 TabBar on screen.
    so, my version will upgrade. to 'walk thru' all tabs in the collection, even those not displayed on screen.

    :)

    God bless the free sharers !! :)

    -------------------------  Visual Basic 5.00


    Attribute VB_Name = "Module1"

    '''   référence dans le projet à faire à : Accessibility - oleacc.dll
    '''
    Declare Function AccessibleObjectFromWindow Lib "oleacc" _
        (ByVal hwnd As Long, ByVal dwId As Long, _
        riid As tGUID, ppvObject As Object) As Long

    Declare Function AccessibleChildren Lib "oleacc" _
        (ByVal paccContainer As IAccessible, ByVal iChildStart As Long, _
         ByVal cChildren As Long, rgvarChildren As Variant, _
         pcObtained As Long) As Long
        
    Type AccObject
        objIA As IAccessible
        lngChild As Long
    End Type

    Type tGUID
        lData1            As Long
        nData2            As Integer
        nData3            As Integer
        abytData4(0 To 7) As Byte
    End Type

    Type RECT
       Left As Long
       Top As Long
       Right As Long
       Bottom As Long
       End Type

    Dim oIA     As IAccessible
    Dim tg      As tGUID
    Dim lReturn As Long
    Dim IBreak  As Long
    Dim NbOnglet As Long
    Dim ct1 As Long
    Dim ct2 As Long
    Dim ct3 As Long
    Dim ct4 As Long
    Dim ct5 As Long
    Dim ct6 As Long
    Dim ct7 As Long

    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
       (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
        ByVal lpsz2 As String) As Long

       
    'Retrieve the IAccessible interface from a window handle
    'Reference:Jean Ross,Chapter 17: Accessibility in Visual Basic,Advanced Microsoft Visual Basic 6.0, 2nd Edition
    Function IAccessibleFromHwnd(hwnd As Long) As IAccessible
        ' Define the GUID for the IAccessible object
        ' {618736E0-3C3D-11CF-810C-00AA00389B71}
        With tg
            .lData1 = &H618736E0
            .nData2 = &H3C3D
            .nData3 = &H11CF
            .abytData4(0) = &H81
            .abytData4(1) = &HC
            .abytData4(2) = &H0
            .abytData4(3) = &HAA
            .abytData4(4) = &H0
            .abytData4(5) = &H38
            .abytData4(6) = &H9B
            .abytData4(7) = &H71
        End With
        ' Retrieve the IAccessible object for the form
        lReturn = AccessibleObjectFromWindow(hwnd, 0, tg, oIA)
        Set IAccessibleFromHwnd = oIA
    End Function

    Function FindAccessibleChildInWindow(hwndParent As Long, IndOnglet As Long, lngRole As Long) As AccObject
        Dim oButton As AccObject
        Dim oParent As IAccessible
       
        Set oParent = IAccessibleFromHwnd(hwndParent)
        If oParent Is Nothing Then
            Set FindAccessibleChildInWindow.objIA = Nothing
        Else
            FindAccessibleChildInWindow = FindAccessibleChild(oParent, IndOnglet, lngRole)
            'oButton = FindAccessibleChild(oParent, strName, lngRole)
            'oButton.objIA.accDoDefaultAction oButton.lngChild
            'FindAccessibleChildInWindow = oButton
        End If
    End Function

    'Recursively looking for a child with specified accName and accRole in the accessibility tree
    Function FindAccessibleChild(oParent As IAccessible, IndOnglet As Long, lngRole As Long) As AccObject
        Dim oButton As AccObject
        Dim lHowMany    As Long
        Dim avKids()    As Variant
        Dim lGotHowMany As Long, i As Integer
        Dim oChild      As IAccessible
           
        FindAccessibleChild.lngChild = CHILDID_SELF
        If oParent.accChildCount = 0 Then
            Set FindAccessibleChild.objIA = Nothing
            Exit Function
        End If
        lHowMany = oParent.accChildCount
        ReDim avKids(lHowMany - 1) As Variant
        lGotHowMany = 0
        If AccessibleChildren(oParent, 0, lHowMany, avKids(0), lGotHowMany) <> 0 Then
            MsgBox "Error retrieving accessible children!"
            Set FindAccessibleChild.objIA = Nothing
            Exit Function
        End If
        'To do: the approach described in http://msdn.microsoft.com/msdnmag/issues/0400/aaccess/default.aspx
        ' are probably better and more reliable
        ct1 = lGotHowMany + ct1
        IBreak = IBreak + 1
        'MsgBox "ct1: " & ct1 & "  - IBreak: " & IBreak
        lGotHowManyM1 = lGotHowMany - 1
        On Error Resume Next
        For i = 0 To lGotHowManyM1
            If IsObject(avKids(i)) Then
            ''' pas de controle sur libelle  avKids(i).accName
                abc = avKids(i).accName
                bcd = avKids(i).accRole
                cde = avKids(i).Caption
                ct2 = ct2 + 1
                'MsgBox "ct2: " & ct2 & " - abc: " & abc & " - bcd: " & bcd & " - caption: " & cde _
                  & " - I: " & i & " - lGotHowMany-1: " & lGotHowManyM1
                If IBreak = 4 Then
                    ' onglet à traiter
                    'avKids(i).accDoDefaultAction avKids(i).lngChild
                    'MsgBox avKids(i).lngChild ' avKids(i).accDoDefaultAction ' & " - " & avKids(i).lngChild
                    NbOnglet = NbOnglet + 1
                End If
                ' bool1 = avKids(i).accName Is Empty And avKids(i).accRole Is Empty ' Then
                'If IBreak = 4 And StrComp(avKids(i).accName, strName) = 0 And avKids(i).accRole = lngRole Then
                If IBreak = 4 Then ' And bool1 Then
                    ct5 = ct5 + 1
                    'NbOnglet = NbOnglet + 1
                    If NbOnglet = IndOnglet Then
                      Set FindAccessibleChild.objIA = avKids(i)
                      FindAccessibleChild.objIA.accDoDefaultAction FindAccessibleChild.lngChild
                      Exit For
                    End If
                    If NbOnglet = lGotHowMany Then
                      MsgBox "Dernier onglet : celui de 'création d'un nouvel onglet'"
                    Else
                      'MsgBox "Onglet: " & NbOnglet & " /" & lGotHowMany & " activé.   (" & _
                        lGotHowManyM1 & " onglets + celui de 'création d'un nouvel onglet')"
                    End If
                Else
                    ct6 = ct6 + 1
                    Set oChild = avKids(i)
                    FindAccessibleChild = FindAccessibleChild(oChild, IndOnglet, lngRole)
                    If Not FindAccessibleChild.objIA Is Nothing Then
                        ct7 = ct7 + 1
                        Exit For
                    End If
                End If
            Else
                ct3 = ct3 + 1
                If StrComp(oParent.accName(avKids(i)), strName) = 0 And oParent.accRole(avKids(i)) = lngRole Then
                    ct4 = ct4 + 1
                    Set FindAccessibleChild.objIA = oParent
                    FindAccessibleChild.lngChild = avKids(i)
                    Exit For
                End If
            End If
        Next i
    End Function

    Function Main(IndOnglet As Long) As Long
        On Error Resume Next
        'MsgBox "Main : H:\Projet\Outils\VB 5.00\Gestion_Onglets_IE: " & IndOnglet
        Const S_OK = 0
        Dim oButton As AccObject, w&
       
        w = FindWindowEx(0, 0, "IEFrame", vbNullString)
        w = FindWindowEx(w, 0, "CommandBarClass", vbNullString)
        w = FindWindowEx(w, 0, "ReBarWindow32", vbNullString)
        w = FindWindowEx(w, 0, "TabBandClass", vbNullString)
        w = FindWindowEx(w, 0, "DirectUIHWND", vbNullString)
       
            ' Retrieve the IAccessible object for the form
        Set oIA = IAccessibleFromHwnd(w)
        If lReturn <> S_OK Then Main = 999: Exit Function
        'MsgBox lReturn & "  - oIA.accChildCount: " & oIA.accChildCount
        oButton = FindAccessibleChildInWindow(w, IndOnglet, 0)  ' "Système", 2)  ' "Application", 2)
    End Function


    -----------------------------------

    (people reading, do nothing bad on one other's computer with ''my help'', my spirit could be a sword)

    best regard :)
    • Proposed as answer by nayR_Inverted Saturday, August 9, 2014 9:26 PM
    Wednesday, January 7, 2009 9:37 AM
  • THIS IS THE END OF IE INTERNET EXPLORER.... NO ONE GOING TO USE IT ANYMORE.

     

     

    i WILL BE USING .. FIREFOX AND CHROME.... THIS IS THE DOWNFALL OF IE.... TABS SLOW AND  NOT WORKING AND MESSING UP MY WORK...YOU SUX

    Friday, July 2, 2010 11:00 AM
  • Ty For Sharing..

    Trying to Automate the File upload Process in IE 11..

    DirectUIHWND, Child SysListView32,select 1st - End.

    Although this code doesnt show exactly how to do what i want I am going to use it as a basis to work from. Thank you for sharing.

    So I will try to Find this thread again and share my code, so maybe DirectUIHWND can be less 'undocumented' and used in a easy way...On Windows 8.1... which as I hear is being scrapped for the upcoming Windows 9..

    Search terms used to dig up information about excel VBA oleacc Accessibility I used:Excel lib Oleacc IAcessible DirectUIHWND

    I could have added some reductions by adding not python, But -!= +.  enjoy the somewhat reduced search results from google, and peace to you fellow fravia.


    • Edited by nayR_Inverted Saturday, August 9, 2014 9:40 PM Spelling, refining my wording.
    Saturday, August 9, 2014 9:36 PM