Hey All,

another problem :) I am trying to write code that on hitting a button will open and program, a "ok" window appears when program is open so I want the code to keystroke RETURN. I am using MSVC 6 MFC. I have gotten (painfuly) to the stage where I hit the button and the program opens and the "ok" window appears but my keystroke operation to hit the RETURN button doesnt seem to be working, here is the code:

HANDLE hEvent;
void CLinkerProgramDlg::OnSim() 
{
	// TODO: Add your control notification handler code here

	ShellExecute(this->m_hWnd,"open",
    "\EvolveTraffic.exe","","", SW_SHOW );

hEvent = CreateEvent(NULL,FALSE,FALSE,"EvolveTraffic");
WaitForSingleObject(hEvent,INFINITE);



keybd_event(VK_RETURN,0x1c,0 , 0); // Press Enter
keybd_event(VK_RETURN,0x9c,KEYEVENTF_KEYUP,0); // Release Enter

}

has anyone any idea where I am going wrong. Thanks again for all the help.

Colm

Have it sorted, using:

WaitForSingleObject(hEvent,50);

works :)

Colm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.