简体   繁体   中英

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. Is there a function that can do that? I've tried FindWindow but it doesn't seem to go through ALL the windows.

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.

EnumWindows

Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function.

You can use GetClassName , GetWindowText to retrieve the name of the class and the text of the specified window's title bar respectively. See the ScreenCaptureforHWND example.
For the others, as @IInspectable said, use EnumChildWindows . But as far as Visual Studio is concerned, EnumWindows is enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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