I've spent my Saturday writing a program which now works perfectly well and I spent this morning making it look nice.
However, I want to make it run at the right time automatically, instead of waiting for a user to start it when needed.
The basic problem is, that in a WinPE environment an exe is running. Unfortunately it would need critical input, which must be inputted perfectly. So, I wrote a program which gets the data and sends it to the other app, by bringing it to the front and presses the keys needed using SendInput().
However, this program should wait for it's cue, then get on the inputting part. It's cue should be the point where the program waits for the first user input with this displayed on the last line:
My question is: how to listen and check whether the last line displayed is "Text:"?
I've tried with AttachConsole(), but for some reason it opens a new console window. I checked and the PID I'm using is the console window's, so I don't know why that happens.
The few lines I'm trying with:
HWND hwnd = FindWindow(NULL, "Administrator: Command Prompt");
ReadConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), lastline, 5, pos, &dwChars)
cout << dwChars << endl;
Please don't criticize the first line. I know it can be ambiguous, but I modified it, so it can be tested at home by anyone using an admin prompt. When actually using it, the exe name will be in the title, so it will be unique.
Thanks in advance!