I'm developing a small utility application that needs to detect whether another one has one of its MDI child windows open (it's an off-the-shelf Win32 business application over which I have neither source code nor control). From my app, I would like to be able to poll or detect when a particular MDI Child window is open.
In .Net, it's easy to iterate over running processes, but I haven't found an easy way to iterate through the (sub)windows and controls of a given Win32 process from .Net.
Any ideas?
Update
Thanks for the answers they got me on the right path.
I found an article with a test project that uses both EnumWindows
and EnumChidWindows
and other API calls to get extended information on controls.
You must use native Win32 API.
EnumChildWindows (user32)
This is an old post, but a common problem. I have a similar situation where I'm trying to control the behaviour of an off-the-shelf software application. I mostly succeeded by using Kixstart, but came up against the limitations of using SETFOCUS and SENDKEYS because at certain points the off-the-shelf software is displaying windows where WindowTitle is blank. So I developed a little utility which identifies visible Windows by their ProcessName as well as WindowTitle (or lack thereof) and sends a message to close a window which matches.
Most of the examples I've seen of EnumWindows callback functions ignore windows which aren't visible or which have blank titles, whereas this code enumerates all windows including invisible ones.
This code is Visual Basic and uses a configuration file in the format
Hope this is useful to somebody
You can use P/Invoke to access EnumWindows and EnumChidWindows to itereate through the subwindows/controls of any window.