views:

73

answers:

1

I'm trying to find all the windows of ANY kind that are open (and have a taskbar 'button').

I have no problems finding the list processes/hWnd's, and then cycling through those, but how do I determine if a process/hwnd has a window open? (even if minimized).

I've tried doing different combinations of the window parameters (such as WS_POPUP etc) but none of the parameters (or combinations of parameters) that I could find would give me all the open windows without some sort of false positives. As an example of a false positive was the fact that it gives me two 'windows' for google talk (even though one was open). Another false positive is considering the start menu as an open window.

Any ideas? Solutions? I've been working on this for a while and its been driving me a bit insane.

Note: I'm doing this for windows 7 (at this point). I'm not sure if there's any difference between how you would do this between XP and 7, but I thought it might be relevant.

+1  A: 

Can you use EnumWindows()? That finds only toplevel windows.

[EnumWindows (MSDN)][1]

[1]: http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx "EnumWindows [msdn]

Pat Wallace
EnumWindows is what I've used. It gives you all windows, minimized or otherwise. You then have to use other calls like IsWindowVisible to get the actual status of the window.
Herms
Pat Wallace
Unfortunately, WS_EX_APPWINDOW leaves out a LOT of windows, such as explorer or itunes etc. I just ran it in a test. The issue with a lot of this is that when the windows are created the application creators don't necessarily set the correct flags for them.
Paul