Hi Euroknaller,
This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.
Please tell us which language do you want to use?
You could close the Chrome tabs with following C# code, which will get all Chrome related process and close them. Hope that can help you.
Please add references for UIAutomationClient.dll and UIAutomationTypes.dll into your project.
using System.Diagnostics;
using System.Windows.Automation;
foreach (Process process in Process.GetProcessesByName("chrome"))
{
if (process.MainWindowHandle == IntPtr.Zero) // some have no UI
continue;
AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);
if (element != null)
{
((WindowPattern)element.GetCurrentPattern(WindowPattern.Pattern)).Close();
}
}
Best Regards,
Weiwei
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.