Anyone knows how to get the url from firefox quantum? I know for 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)
Taking a look on this answer and considering the comment of Peter: it's working for me but it takes a while to get the url
I wrote the following code. Maybe it could be helpful to someone:
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
{ }
}
}
}
Important , to make this code to work, your code must reference the COM library: UIAutomationClient
I did it myself with this
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
For me it helped disabling multi-process Firefox (Electrolysis/e10s).
In version 57.0.4 goto about:config
and set:
browser.tabs.remote.autostart=false (default)
browser.tabs.remote.autostart.2=false
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.