Получить URL-адрес из всех открытых вкладок в Google Chrome с помощью VB .Net и UI Automation
Здравствуйте, у меня есть этот код, работающий, чтобы получить текущий URL в Chrome, но только получить активный URL-адрес вкладки. Мне нужно получить URL-адрес из всех открытых вкладок с помощью автоматизации пользовательского интерфейса.
Мой рабочий код:
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
и вызвать его, используя этот код в событии загрузки формы:
For Each proc As Process In Process.GetProcessesByName("chrome")
MsgBox(proc.MainWindowTitle + " " + GetChromeUrl(proc))
Next