/*----------------------------------------
 win32  console application by Yamato 1997 
 little utility to see all windows in the system, even those hidden
 you can unhide any window you want
-----------------------------------------*/

#include <stdio.h>
#include <conio.h>
#include <windows.h>

#define MAXWINDS 300
#define MAXLINES 23


typedef struct
{
	int status;
	HWND hwnd;
	char text[100];
} stat;

stat winds[MAXWINDS];
int count=0;


BOOL CALLBACK myWinProc(HWND hwnd, LPARAM lParam)
{
	char title[100];

	GetWindowText(hwnd,title,99);
	//printf("hwnd=%d, title=%s\n",hwnd, title );

	winds[count].hwnd = hwnd;
	strcpy(winds[count].text, title);
	count++;

	return TRUE;
}

void main()
{
	//HWND hDesktop;
	int i,idx;
	int c;

	if(EnumWindows( (WNDENUMPROC)myWinProc, 77) == 0) 
	{
		printf("failed\n");
		return;
	}
	
	printf("No\tStatus\tHwnd\tName\n");
	for(i=0;i<count;i++)
	{
		printf("%d\t%d\t%d\t%s\n",i,winds[i].status,
			winds[i].hwnd,winds[i].text);
		if( (i+1)%MAXLINES == 0 ) 
		{
			//maximum lines per page reached
			printf("press any key to continue");
			getch();
			printf("\nNo\tStatus\tHwnd\tName\n");

		}
	}
	printf("\nWhich index?");
	scanf("%d", &idx);
	printf("\nWhat?");
	c= toupper( getch() );
	
	if( c == 'H' )
		ShowWindow(winds[idx].hwnd, SW_HIDE);
	else ShowWindow(winds[idx].hwnd, SW_SHOW);
}





