得到所有打开的窗口标题窗口、标题

2023-09-02 20:43:12 作者:甜磕

我如何可以检索所有打开的窗口的标题(包括窗口,例如在Internet Explorer中的选项卡)?

How can I retrieve the titles of all open windows (including windows such as tabs in Internet Explorer)?

推荐答案

事情是这样的:

using System.Diagnostics;

Process[] processlist = Process.GetProcesses();

foreach (Process process in processlist)
{
    if (!String.IsNullOrEmpty(process.MainWindowTitle))
    {
        Console.WriteLine("Process: {0} ID: {1} Window title: {2}", process.ProcessName, process.Id, process.MainWindowTitle);
    }
}