How would I minimize all the open windows from within a C program? I want the desktop to have the focus. How do I do this? I have tried SetForegroundWindow(), SetFocus(), and SetActiveWindow() and I still can not make it work.
How would I minimize all the open windows from within a C program? I want the desktop to have the focus. How do I do this? I have tried SetForegroundWindow(), SetFocus(), and SetActiveWindow() and I still can not make it work.
You will need to use EnumWindows() to get a list of all open windows.
Once you have the list you need to check IsWindowVisible() to find the ones that are showing.
Then ShowWindow() will let you minimize them.
Finally GetDesktopWindow() and SetFocus() will allow you to give the desktop focus.
How about an example? actually, I can figure out all the functions except EnumWindows(). Could you give me an example snippet of code that would use that function?
Compiler: GCC
Here's one. Don't worry, I've also little idea of what I was trying to accomplish with it. Still, shows you how it can be used. Or you could just use SendInput to send Win+D
Last edited by adeyblue; 04-20-2011 at 05:16 PM.
The documentation at MSDN is fairly complete...
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Google is your friend.
Basically the EnumWindows() function cycles through the Zorder giving window handles to it's callback procedure one at a time. The callback is written by you... That's where you determine if a window is visible and call the ShowEindow() function with SW_MINIMIZE to close itl down into the taskbar.
Last edited by CommonTater; 04-20-2011 at 05:46 PM.
CommonTater, I already looked at MSDN. Couldn't make any sense out of it.
Thanks a lot, adeyblue.
Last edited by CommonTater; 04-20-2011 at 06:25 PM.