Holen Sie sich URL von allen offenen Tabs in Google Chrome mit VB .Net und UI Automation
Hallo, ich habe diesen Code, um die aktuelle URL in Chrome abzurufen, aber nur die aktive Tab-URL. Ich muss URL von allen geöffneten Vorsprüngen erhalten, die UI-Automatisierung verwenden.
Mein Arbeitscode:
Function GetChromeUrl(ByVal proc As Process) As String
If proc.MainWindowHandle = IntPtr.Zero Then
Return Nothing
End If
Dim element As System.Windows.Automation.AutomationElement = AutomationElement.FromHandle(proc.MainWindowHandle)
If element Is Nothing Then
Return Nothing
End If
Dim edit As System.Windows.Automation.AutomationElement = element.FindFirst(TreeScope.Children, New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit))
Return (edit.GetCurrentPattern(ValuePattern.Pattern)).Current.Value.ToString
End Function
und rufen Sie es mit diesem Code im Ereignis Form Load auf:
For Each proc As Process In Process.GetProcessesByName("chrome")
MsgBox(proc.MainWindowTitle + " " + GetChromeUrl(proc))
Next