2
Я пытаюсь прочитать URL-адрес TITLE & из браузера Microsoft EDGE. Выполнение этого с помощью System.Windows.Automation наиболее предпочтительно, поскольку база кода уже использует это для других проблем.Чтение Edge Browser Title & Url with System.Windows.Automation
- Возможно ли использование системы.Windows.Automation?
- Как получить доступ к URL-адресу?
Я в настоящее время это далеко:
AutomationId "TitleBar"
ClassName "ApplicationFrameWindow"
Name = [string]
=> Reading out this element gives me the TITLE
=> Walking it's children, I find the item "addressEditBox":
AutomationId "addressEditBox"
ClassName "RichEditBox"
Name "Search or enter web address"
=> I always get back the string "Search or enter web address"
=> This is the control where the url is in, though it isn't updated as the user goes to a website, it always returns a fixed string.
В коде:
var digger1 = AutomationElement.FromHandle(process.MainWindowHandle).RootElement.FindAll(TreeScope.Children, Condition.TrueCondition);
foreach(AutomationElement d1 in digger1 {
if(d1.Current.ClassName.Equals("ApplicationFrameWindow")) {
var digger2 = d1.FindAll(TreeScope.Children, Condition.TrueCondition);
foreach(AutomationElement d2 in digger2) {
if(d2.Current.ClassName.Equals("Windows.Ui.Core.CoreWindow")) {
var digger3 = d2.FindAll(TreeScope.Children, Condition.TrueCondition);
foreach(AutomationElement d3 in digger3) {
if(d3.Current.AutomationId.Equals("addressEditBox")) {
var url = d3.Current.Name;
return url;
}
}
}
}
}
}
Спасибо, попробуем это как можно скорее! Я не понял API System.Windows.Automation, я думаю:) ... Спасибо. –
Этот метод работает только при максимальном увеличении окна EDGE. Можете ли вы предложить, как заставить его работать, если EDGE сведен к минимуму? –
Поскольку МАУ не видит края, если оно минимизировано –