Firefox Quantum obtener url (VB.Net/C#)

¿Alguien sabe cómo obtener la url de Firefox Quantum? Lo sé por Firefox:

Dim DdeClient As New DdeClient("Firefox", "WWW_GetWindowInfo") DdeClient.Connect() Dim URL As String = DdeClient.Request("URL", Integer.MaxValue) DdeClient.Disconnect() URL = Split(URL, """,""")(0) URL = Split(URL, """")(1) 

Yo mismo lo hice con esto

  Dim ProcessFireFox As Process() = Process.GetProcessesByName("firefox") If ProcessFireFox.Count = 0 Then MsgBox("firefox not found", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error") Exit Sub End If For Each Firefox As Process In ProcessFireFox If Firefox.MainWindowHandle = IntPtr.Zero Then Continue For Dim AutomationElement As System.Windows.Automation.AutomationElement = System.Windows.Automation.AutomationElement.FromHandle(Firefox.MainWindowHandle) For Each Elm As System.Windows.Automation.AutomationElement In AutomationElement.FindAll(TreeScope.Descendants, New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)) Dim BAutomationPattern As System.Windows.Automation.AutomationPattern() = Elm.GetSupportedPatterns() Dim BValuePattern As System.Windows.Automation.ValuePattern = DirectCast(Elm.GetCurrentPattern(BAutomationPattern(0)), System.Windows.Automation.ValuePattern) MsgBox(BValuePattern.Current.Value.ToString) Next Next 

Para mí, ayudó a desactivar Firefox multiprocesos (Electrolysis / e10s).

En la versión 57.0.4 goto about:config and set:

browser.tabs.remote.autostart=false (default)
browser.tabs.remote.autostart.2=false

Echar un vistazo a esta respuesta y considerar el comentario de Peter: it's working for me but it takes a while to get the url

Escribí el siguiente código. Tal vez podría ser útil para alguien:

  Process[] lFFs = Process.GetProcessesByName("firefox"); for (int i = 0; i < lEs.Length; i++) { UIAutomationClient.IUIAutomationElement ee = lEs.GetElement(i); if (ee != null && ee.CurrentName != null && (ee.CurrentName.Contains("search") || ee.CurrentName.Contains("navigation"))) { // For spanish you can use: (ee.CurrentName.Contains("de búsqueda") || ee.CurrentName== "Barra de navegación") lEs = ee.FindAll(UIAutomationClient.TreeScope.TreeScope_Children, c); if (lEs.Length > 0) i = 0; else { try { object obj = ee.GetCurrentPattern(10002); // 10002: ValuePattern if (obj != null) { string sUrl = ((UIAutomationClient.IUIAutomationValuePattern)obj).CurrentValue; return sUrl; } } catch { } } } } 

Importante , para hacer que este código funcione, su código debe hacer referencia a la biblioteca COM: UIAutomationClient