Not a very good idea (why just sending your application on top is not enough?), but…
You need to be able to minimize a window by its HWND. To do this, use P/Invoke and Windows API
SetWindowPlacement
, see
http://msdn.microsoft.com/en-us/library/ms633544(v=vs.85).aspx[
^]. Let's assume you did it and wrapped it in a method
MinimizeWindow(System.IntPtr hwnd)
.
Now, where to get all windows?
I would prefer using pure .NET library, not more P/Invoke:
static void MinimizeAll() {
System.Diagnostics.Process thisProcess =
System.Diagnostics.Process.GetCurrentProcess();
System.Diagnostics.Process[] processes =
System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process process in processes) {
if (process == thisProcess) continue;
System.IntPtr handle = process.MainWindowHandle;
if (handle == System.IntPtr.Zero) continue;
MinimizeWindow(handle);
}
}
That's it. Pretty simple, isn't it?
—SA