在Windows XP上,如何枚举系统显示的所有窗口(C#)

时间:2022-10-30 10:42:23

I would like to end up with a list (or array or whatever) of all the visible (including minimised) windows.

我想最终得到所有可见(包括最小化)窗口的列表(或数组或其他)。

I have found 2 similar questions, which don't quite give me what I'm looking for:
- Work out which windows go in the alt-tab list
- list windows in another user's session

我找到了两个类似的问题,这些问题并不能完全解决我想要的问题: - 在alt-tab列表中查找哪些窗口 - 在另一个用户的会话中列出窗口

Thanks.

3 个解决方案

#1


I think that the blog entry by Raymond Chen pointed to in the first link gives you an idea of where you want to go. Basically, you would call EnumWindows and then apply that algorithm, except that you would take note of every window handle that is visible.

我认为Raymond Chen在第一个链接中指出的博客条目让你知道你想去哪里。基本上,你会调用EnumWindows然后应用该算法,除了你会注意到每个可见的窗口句柄。

The question is a little vague, what is the purpose here (there might be a better way given more info).

问题有点模糊,这里的目的是什么(给出更多信息可能有更好的方法)。

#2


How about this to get a list of processes that would go into the alt-tab list. (Running processes that contain a window):

如何获取进入alt-tab列表的进程列表。 (运行包含窗口的进程):

using System.Diagnostics.Process; 

List<Process> plist = new List<Process>();            

foreach (Process p in Process.GetProcesses())
{
 string title = p.MainWindowTitle;
 if (!String.IsNullOrEmpty(title))
 {
     plist.Add(p);
 }
}

#3


Just use EW() api (win32 FAQ)

只需使用EW()api(win32 FAQ)

#1


I think that the blog entry by Raymond Chen pointed to in the first link gives you an idea of where you want to go. Basically, you would call EnumWindows and then apply that algorithm, except that you would take note of every window handle that is visible.

我认为Raymond Chen在第一个链接中指出的博客条目让你知道你想去哪里。基本上,你会调用EnumWindows然后应用该算法,除了你会注意到每个可见的窗口句柄。

The question is a little vague, what is the purpose here (there might be a better way given more info).

问题有点模糊,这里的目的是什么(给出更多信息可能有更好的方法)。

#2


How about this to get a list of processes that would go into the alt-tab list. (Running processes that contain a window):

如何获取进入alt-tab列表的进程列表。 (运行包含窗口的进程):

using System.Diagnostics.Process; 

List<Process> plist = new List<Process>();            

foreach (Process p in Process.GetProcesses())
{
 string title = p.MainWindowTitle;
 if (!String.IsNullOrEmpty(title))
 {
     plist.Add(p);
 }
}

#3


Just use EW() api (win32 FAQ)

只需使用EW()api(win32 FAQ)