简体   繁体   中英

Get opened tabs information of Firefox?

I'm trying to write a simple program that should search in Firefox window for duplicated tabs (checking the url of the tab) and then close the found duplicated tabs.

The idea is simple, but the implementation seems a nightmare.

Doing a lot of researchs messing with WinAPI I've found nDde library, which could retrieve the url of the current tab easy like this example:

VB.NET

    Imports NDde.Client

    Using dde As New DdeClient("Firefox", "WWW_GetWindowInfo")

        dde.Connect()

        Dim Url As String = dde.Request("URL", Integer.MaxValue).
                                Trim({ControlChars.NullChar, ControlChars.Quote, ","c})

        MessageBox.Show(Url)

        dde.Disconnect()

    End Using

C#:

using (DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo")) {

    dde.Connect();

    string Url = dde.Request("URL", int.MaxValue).Trim({
        ControlChars.NullChar,
        ControlChars.Quote,
        ','
    });

    MessageBox.Show(Url);

    dde.Disconnect();

}

//=======================================================
//Service provided by Telerik (www.telerik.com)
//Conversion powered by NRefactory.
//Twitter: @telerik
//Facebook: facebook.com/telerik
//=======================================================

But my knowledges about this library or dde in general are zero, so what I'm doing by the moment is sending ctrl+Tab keys to Firefox to change between tabs to get the url of each tab and then close duplicated founds sending ctrl+w , but this way I have not a reference point to know which tab was the "starting point" to know when I need to stop the dup-tab searching 'cause the first checked url could have a duplicated tab too, and also I can't know the exact number of opened tabs to have an Index reference.

I'm lost.

My question is, this library (or another library related to dde, or another totally different way) could retrieve at least one of those things in a dynamic way?:

· The url of the first tab, I mean the tab that is at the top-left, the first of all opened tabs.

· The total amount count of opened tabs.

· The url of all tabs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM