Hey all,
need abit of help bringing a .exe window which has been previously open in my program.On a button click the program window should be brought to the front with "Alt+S" to be pressed. I am using MSVC 6 MFC and my code looks like:
void CEvolveTraffic::OnButton()
{
// TODO: Add your control notification handler code here
HANDLE hEvent;
HWND hWnd = ::FindWindow(NULL,"Program.exe");
::SetForegroundWindow(hWnd);
hEvent = CreateEvent(NULL,FALSE,FALSE,"Program");
WaitForSingleObject(hEvent,50);
keybd_event(VK_MENU, 0, 0, 0); // Press Alt
keybd_event(VkKeyScan('T'),0x14,0 , 0); // Press S
keybd_event(VkKeyScan('T'),0x9,KEYEVENTF_KEYUP,0); // Release S
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Release Alt
}
I am getting no complier errors but the program window is not coming to the front :? anyone got any ideas, thanks
Colm.