C # get urls of all open pages in Firefox

I'm already here:

I know there are many questions in this thread, but none of them answer it correctly. I am curious how to get the url of all open pages in firefox, but I can't find a solution that provides working code.

This is the most expensive solution on the web, but it doesn't work for me. This code uses DDE (which used NDDE - a good DDE wrapper for .NET):

private string GetBrowserURL(string browser)
{
    try
    {
        DdeClient dde = new DdeClient(browser, "WWW_GetWindowInfo");
        dde.Connect();
        string url = dde.Request("URL", int.MaxValue);
        string[] text = url.Split(new string[] { "\",\"" }, StringSplitOptions.RemoveEmptyEntries);
        dde.Disconnect();
        return text[0].Substring(1);
    }
    catch
    {
        return null;
    }
}

      


I'm not interested if it shows history, gets urls of open pages in second Firefox window, I want to keep it simple. Please do not provide me with the code for another browser as it always depends on the browser or any VB code.

+3


source to share


1 answer


This works even if you are using Firefox> 49:



System.Windows.Automation.AutomationElement AutomationElement = System.Windows.Automation.AutomationElement.FromHandle(ptr);
System.Windows.Automation.AutomationElement Elm = AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document));
System.Windows.Automation.AutomationPattern[] BAutomationPattern = Elm.GetSupportedPatterns();
System.Windows.Automation.ValuePattern BValuePattern = (System.Windows.Automation.ValuePattern)Elm.GetCurrentPattern(BAutomationPattern[0]);
CurrentUrlName = BValuePattern.Current.Value.ToString();

      

-1


source







All Articles