Is there any way of getting information about the currently active *window* in another application/process

Question

> Is there any way of getting information about the
currently active
> > *window* in another application/process (i.e.
windowgroup)? Getting
> > the ID of a window group is easy, but there doesn't
seem to be any
> > way of getting information about child windows. Just
enumerating
> > them would be enough for me.

Answer

(Note that the phone app dialogs have changed since I wrote this, and
the dialog detection doesn't work on anything above the 6600).

Sadly, no. It is quite possible that this information really is not made
externally available by the window server.

In my case, I was interested in knowing whether the phone app is
currently showing a dialog/menu or whether it is idle. This can be
approximated with the following code, which checks for the edge of the
dialog/menu window:

void screen::ConstructL()
{
	screenDevice = CEikonEnv::Static()->ScreenDevice();
	
	black=0;
	gray=221;
}

bool screen::dialog_on_screen()
{
	TSize size=screenDevice->SizeInPixels();

	TBuf8<200> scan1;
	TBuf8<200> scan2;

	TInt w=size.iWidth;
	if (w>200) w=200;

	screenDevice->GetScanLine(scan1, TPoint(0, size.iHeight-27), w,
 		EColor256);
	screenDevice->GetScanLine(scan2, TPoint(0, size.iHeight-26), w,
 		EColor256);

	bool dialog=true;
	for (int i=10; i<w-10; i++) {
		if (scan1[i]!=black) {
			dialog=false;
			break;
		}
		if (scan2[i]!=gray) {
			dialog=false;
			break;
		}
	}
	
	return dialog;
}


Of course this is vulnerable at least to background images with the same
arrangement of pixels, and maybe to color scheme changes. The position
of the edge was determined experimentally.