#pragma warning(disable:4129)//escape keys #include #include #include "dll.h" #define PARENTWND "Wolf Console" #define CHILDWND "Edit" #define MAX_BUFFER 16384 #define CR 13 //Carriage Return #define LF 10 //Line Feed static HWND hwndParent = NULL; //Get window static HWND hwndEdit = NULL; //Store class ptr static HWND hwndConsole = NULL; //Store class ptr void SetWindowHandles() { hwndParent = FindWindow(0, PARENTWND); hwndEdit = FindWindowEx(hwndParent, NULL, CHILDWND, NULL); //1st edit class hwndConsole = FindWindowEx(hwndParent, NULL, CHILDWND, NULL); //1st edit class hwndConsole = FindWindowEx(hwndParent, hwndEdit, CHILDWND, NULL); //2nd edit class - text stored here } void ConsoleWrite(char *String) { SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM)String); SendMessage(hwndEdit, WM_CHAR, CR, 0); //Simulate Carriage Return ('Enter') } char* GetConsoleLastLine() { char sBuf[MAX_BUFFER]; char *sLastLine; char sLine[1024]; char *pEnd, *pStart; int iLen, i; iLen = i = 0; pEnd = pStart = sBuf; if ((sLastLine = (char *) malloc(1024))==NULL) return 0; SendMessage(hwndConsole, WM_GETTEXT, MAX_BUFFER, (LPARAM)sBuf); iLen = strlen(sBuf); // get console buf len pEnd = sBuf + ((sizeof(char)*iLen)-4); // get a ptr to EOC (end of console) pStart = pEnd; while(*--pStart != LF) // copy the string backwards from EOC to previous line sLine[i++] = *pStart; // move ptr backwards until CR/LF = end of previous line sLine[i] = '\0'; // terminate your strings noobs. i = 0; pEnd = pStart; while(*pEnd++) // reverse the string sLastLine[i++] = *pEnd; sLastLine[i] = '\0'; // terminate your strings noobs. return sLastLine; // return ptr to copy of last line } int ConsoleScan(char *String) { char* pszConsoleLine = GetConsoleLastLine(); int iRet = (int)strstr(pszConsoleLine, String); free(pszConsoleLine); //cleanup return(iRet); } int main() { Sleep(10000);//enough time to open game SetWindowHandles(); while(1) { if(ConsoleScan("Dynamite Planted")) { ConsoleWrite("\echo ^1Found TEST in consoles last line!"); break; } } }