C#获取Firefox中所有打开页面的URL

C#获取Firefox中所有打开页面的URL,c#,url,firefox,C#,Url,Firefox,我已经来过这里了: 我知道关于这个话题已经有很多问题了,但是没有一个正确回答。我很好奇如何获取firefox中所有打开页面的URL,但我没有找到一个提供工作代码的解决方案 这是互联网上回报最高的解决方案,但对我来说不起作用。 这段代码使用DDE(它使用NDDE-一个很好的.NET DDE包装器): 我不在乎它是否显示历史,是否在第二个Firefox窗口中获取打开页面的URL,我想现在保持它的简单。请不要向我提供其他浏览器的代码,因为它总是特定于浏览器或任何VB代码。即使您使用Fi

我已经来过这里了:

我知道关于这个话题已经有很多问题了,但是没有一个正确回答。我很好奇如何获取firefox中所有打开页面的URL,但我没有找到一个提供工作代码的解决方案

这是互联网上回报最高的解决方案,但对我来说不起作用。 这段代码使用DDE(它使用NDDE-一个很好的.NET DDE包装器):



我不在乎它是否显示历史,是否在第二个Firefox窗口中获取打开页面的URL,我想现在保持它的简单。请不要向我提供其他浏览器的代码,因为它总是特定于浏览器或任何VB代码。

即使您使用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();

为什么VB代码与C几乎一样?如果你在寻找复制粘贴解决方案,那你就找错地方了。我知道,我的目的不是要得到一个干净的复制粘贴解决方案,这不是编程热情的所在。但我对C有点陌生,所以老实说,我不知道如何处理VB。
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();