Click to See Complete Forum and Search --> : Sending a keystroke (F5) to an MS-DOS external app


Makis Paleologou
April 28th, 1999, 03:57 AM
My MFC app ( VC++ 5.0, Win95) executes an MS-DOS app through the command line argument of CreateProcess(). The DOS app
runs in a hidden Window and its output is redirected to a CEdit control of the calling process, as described in Matt Brunk's article:
Codeguru/misc/"Redirecting Standard Output to a CEdit control".
What I need to do is to simulate and send to the DOS app an F5 keystroke, which will terminate the execution before normal
completion. I've tried using


HWND hWnd = FindWindow( NULL, "C:\\images\\expose.exe");
SetForegroundWindow(hWnd);
DWORD tID = GetWindowThreadId( hWnd, NULL);
if( tID != GetCurrentThreadId())
{
AttachThreadInput(GetCurrentThreadId(), tID, TRUE);
}
keybd_event( VK_F5, 0, 0, 0);
Sleep(100);
keybd_event( VK_F5, 0, KEYEVENTF_KEYUP, 0);
Sleep(100);



and then detaching the thread input, with no success!
Does anybody have to offer any enlightening idea?
Thanks a lot.

Makis Paleologou