Start of ET


(Rutger) #21

void getConsoleText() {
	HWND window = 0;
	HWND console_edit = 0;
	HWND console_text = 0;
	int length;
	char* buf;
	
	window = FindWindow("ET WinConsole", NULL);
	if (window)
	{
		trap_Print("Window found.
");

		console_edit = FindWindowEx(window, 0, "Edit", NULL);
		console_text = FindWindowEx(window, console_edit, "Edit", NULL);
		if (console_edit && console_text)
		{
			trap_Print("Console edit and text areas found.
");

			length = SendMessage(console_text, WM_GETTEXTLENGTH, 0, 0);
			if (length > -1)
			{
				char * pch;
				buf = (char*) malloc (length+1);

				SendMessage(console_text, WM_GETTEXT, (WPARAM)length, (LPARAM)buf);
				
				pch = strtok (buf,"
");
				while (pch != NULL)
				{
					char * find;
					find = strstr (pch,"PunkBuster");
					if (find != NULL)
					{
						trap_Print("Found punkbuster!
");
					}
					
					pch = strtok (NULL, "
");
				}
			}
		}
	}
}

This seems to work fine, it sees that there is text containing PunkBuster. The find variable contains the position.