Title: Clearing the Desktop
Question: How to (un)minimize all windows?
Answer:
You can use
SendMessage(window_handle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
to maximize one window
so someting like
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MINIMIZE,0);
should minimize all windows; it usually does, except for Win2k, where it exhibits some strange behaviour
So let Explorer do the work:
+'M' minimizes all windows, +'M' restores them
procedure MinimizeAll;
begin
keybd_event(VK_LWIN, MapvirtualKey(VK_LWIN, 0), 0, 0);
keybd_event(Ord('M'), MapvirtualKey(Ord('M'), 0), 0, 0);
keybd_event(Ord('M'), MapvirtualKey(Ord('M'), 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_LWIN, MapvirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
end;
procedure UnMinimizeAll;
begin
keybd_event(VK_LWIN, MapvirtualKey(VK_LWIN, 0), 0, 0);
keybd_event(VK_SHIFT, MapvirtualKey(VK_SHIFT, 0), 0, 0);
keybd_event(Ord('M'), MapvirtualKey(Ord('M'), 0), 0, 0);
keybd_event(Ord('M'), MapvirtualKey(Ord('M'), 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, MapvirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_LWIN, MapvirtualKey(VK_LWIN, 0), KEYEVENTF_KEYUP, 0);
end;
Bogdan Grigorescu - BogdanG@gmail.com
BG Remote Programming Group