0
我想從Chrome瀏覽器中獲取當前網址。當我的瀏覽器使用英語時,我的代碼正在工作。但是當有人使用不同的語言時,由於比較而不起作用。C#如何從Chrome獲取當前網址(多種語言設置)
AutomationElement elm = AutomationElement.FromHandle(p.MainWindowHandle);
AutomationElement elmUrlBar = null;
// elmUrlBar = elm.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Adresse und Suchleiste"));
// if (elmUrlBar != null)
elmUrlBar = elm.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
if (elmUrlBar != null)
{
AutomationPattern[] patterns = elmUrlBar.GetSupportedPatterns();
if (patterns.Length > 0)
{
ValuePattern val = (ValuePattern)elmUrlBar.GetCurrentPattern(patterns[0]);
objSchemeDetail.ProcessName = val.Current.Value;
}
}
我將「地址和搜索欄」改爲德文,但它仍然無效。什麼是替代品?
看起來其他人擁有[相同](https://bugs.chromium.org/p/chromium/issues/detail?id=271227)問題。您可能必須檢查確切翻譯的源代碼。 – wimh
我試過但沒有找到任何源代碼。 –