简体   繁体   English

如何找到具有相同标题栏的 windows 或 class 的号码?

[英]How to find number of windows with the same title bar or class?

I'm trying to get an integer value for the number of windows running with a specific windows class/title.我正在尝试获取运行特定 windows 类/标题的 windows 数量的 integer 值。 Is there a function that can do that?有没有 function 可以做到这一点? I've tried FindWindow but it doesn't seem to go through ALL the windows.我试过FindWindow但它似乎没有通过所有 windows go。

An example of what I am trying to do would be finding the number of Windows a user has open with the "Visual Studio" class.我正在尝试做的一个例子是找到用户使用“Visual Studio”class 打开的 Windows 的数量。

EnumWindows 枚举窗口

Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function.通过将句柄传递给每个 window,依次传递给应用程序定义的回调 function,在屏幕上枚举所有顶级windows。

You can use GetClassName , GetWindowText to retrieve the name of the class and the text of the specified window's title bar respectively.您可以使用GetClassNameGetWindowText分别检索 class 的名称和指定窗口标题栏的文本。 See the ScreenCaptureforHWND example.请参阅ScreenCaptureforHWND示例。
For the others, as @IInspectable said, use EnumChildWindows .对于其他人,正如@IInspectable 所说,使用EnumChildWindows But as far as Visual Studio is concerned, EnumWindows is enough.但就 Visual Studio 而言, EnumWindows就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM