So I want to extract the open tabs from google chrome (title, URL) and list theme out kind of like in the chrome task manager. So far I have tried to filter all the chrome p
didn't found a way to get all URLS, seems like only current active is possible...
but here is my code sample to get all Tab Names even if you seperated them in different windows:
you need
UIAutomationClient.dll
UIAutomationTypes.dll
added to your References as seen above and
using System.Windowsw.Automation
Process[] procsEdge = Process.GetProcessesByName("msedge");
if (procsEdge.Length <= 0)
{
Console.WriteLine("Edge is not running");
}
else
{
foreach (Process proc in procsEdge)
{
//the Edge process must have a window
if (proc.MainWindowHandle != IntPtr.Zero)
{
AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
TreeWalker treewalker = TreeWalker.ControlViewWalker;
AutomationElement rootParent = treewalker.GetParent(root);
Condition condWindow = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window);
AutomationElementCollection edges = rootParent.FindAll(TreeScope.Children, condWindow);
Condition condNewTab = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
foreach (AutomationElement e in edges)
{
//check if the root element is named with *Edge*
if (e.Current.Name.Contains("Edge"))
{
//var beb = e.FindAll(TreeScope.Children, condNewTab);
foreach (AutomationElement tabitem in e.FindAll(TreeScope.Descendants, condNewTab))
{
Console.WriteLine("TABNAME: " + tabitem.Current.Name);
}
}
}
}
}
}
maybe that is helping somebody i realized to late that without the URL's it's not helping me...