0

I had a seemingly bright idea for a cleaner and easier to use operating system feature, for when the Windows clutter just gets too bad.

Basically I want to alter the behavior of every window, such that when it loses focus it is minimized. But I don't know how to do it yet!

Basically so far I plan to:

1. Store a handle to the window in focus (foreground I think it would be).
2. When the window loses focus, send a minimize event.

This is what I have so far.

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	WINDOWPLACEMENT wndPlace; memset(&wndPlace, 0, sizeof(WINDOWPLACEMENT));
	wndPlace.length = sizeof(WINDOWPLACEMENT);
	HWND previousWindow = GetForegroundWindow();
	HWND newWindow;
	while( !GetAsyncKeyState(VK_ESCAPE) )
	{
		newWindow = GetForegroundWindow();
		if((previousWindow != newWindow) && (newWindow != NULL))
		{
			GetWindowPlacement(previousWindow,&wndPlace);
			if( wndPlace.showCmd == SW_SHOWMAXIMIZED || wndPlace.showCmd == SW_SHOWNORMAL )
			{
				ShowWindow(previousWindow,SW_MINIMIZE);
				previousWindow = newWindow;
			}
		}
		Sleep(10);
	}
	return 0;
}

But on Windows 7 there is a "window" that gets minimized that shouldn't be. It messes up my start menu actually, this is my start menu (you can drag it around the screen). Lots of weird behavior with hiding windows that belong to Windows.

What should I do? The behavior is quite nice thus far (minus the bugs). I am considering trying to determine if the windows belong to the OS by the path to their .exe...

Attachments odd_behavior.png 11.83 KB Untitled.png 1.16 KB
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by pseudorandom21
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.