Alex Rivera | Logout

Get location and size of all open windows using .NET (C#)

Asked 2010-08-04T15:06:31.967
12

Is there a way to detect and store the location and size of all open windows, as well as their state (Minimized, Maximized etc)

I've never developed anything that gets information from the actual operating system in this way. Does it require a call to a Windows API and involve unmanaged code?

If this is not clear please comment and I will try to elaborate.

Edit
Report

1 Answer

11

Call EnumWindows to loop through all the windows, then call GetWindowPlacement to get out the information. It will require PInvoke to Windows API, but it's not that difficult, just can find all the information at the PInvoke site.

Btw, here's a codeproject article for finding a specific window and getting/setting the show state of it, might be a good starting point (the code is in VB.Net, but you could probably just use one of the online VB.Net to C# converters if you don't know VB.Net)

answered 2010-08-04T15:15:52.370

Your Answer