c# Getting Chrome URL's from all tab

后端 未结 3 964
北海茫月
北海茫月 2021-01-16 06:18

hi i want to get URL from browsers and for chrome i used these and the is not working getting null exception i think chrome has changed something.. getting error on elm4

3条回答
  •  独厮守ぢ
    2021-01-16 06:58

    Here is the code:

    AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
    Condition condNewTab = new PropertyCondition(AutomationElement.NameProperty, "Novo separador");
    AutomationElement elmNewTab = root.FindFirst(TreeScope.Descendants, condNewTab);
    TreeWalker treewalker = TreeWalker.ControlViewWalker;
    
    // IF THROWS A ERROR HERE, LOOK AT THE AutomationElement.NameProperty ("Novo separador") - PUT THIS TEXT IN APROPRIATE LANGUAGE
    AutomationElement elmTabStrip = treewalker.GetParent(elmNewTab);
                                                                                
    Condition condTabItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
    foreach (AutomationElement tabitem in elmTabStrip.FindAll(TreeScope.Children, condTabItem))
    {
        // HERE IS YOUR TABS!!!!
        ret.Add(tabitem.Current.Name);
    }
    

提交回复
热议问题