2017-10-07 6 views
1

누구나 firefox quantum에서 URL을 가져 오는 방법을 알고 있습니까? 나는 파이어 폭스 알고 :Firefox Quantum get url (VB.Net/C#)

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) 

답변

0

나는 그것이 나 자신은 멀티 프로세스 파이어 폭스 (전기/e10s)을 비활성화하는 도움을 나를 위해이

 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 
+0

안녕하세요, 코드가 여전히 작동인가? 나는 시도했지만 성공하지 못했습니다. @PeterJ – Ayorus

+0

그것은 나를 위해 일하고있다. 그러나 URL을 얻는 데는 시간이 걸린다. – PeterJ

0

로했다. 버전 57.0.4 고토 about:config 및 세트에서

:

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

0

answer에 살펴보면 베드로의 의견을 고려은 :

it's working for me but it takes a while to get the url 나는 다음과 같은 코드를 썼습니다. 어쩌면 누군가에게 도움이 될 수있는이 코드가 작동 할 수 있도록

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 
           { } 
          } 
         } 
        } 

중요, COM 라이브러리 참조해야합니다 코드 : UIAutomationClient