Hello, I need in my MDL app to make a message 'Press ENTER to continue or wait for 5s', but I can not find a way t:
- catch user press
- detect if console is a foreground window
This is what I tried without success (code normally works in console application):
toolSubsystem_printf("Press ENTER to continue or wait for 5s...");
HWND console_wnd = ::GetConsoleWindow();
boost::timer tim;
while ( tim.elapsed() < 5.0 )
{
if (
::GetForegroundWindow() == console_wnd && // does not work in USTN
::GetAsyncKeyState(VK_RETURN) == -32767 ) // does not work in USTN
{
toolSubsystem_printf("\r\n");
break;
}
::Sleep(0);
}
How can I do that?
EDIT: I have also tried getc and toolSubsystem_getStdin but also without success (throws exception due to incpompatibility of FILE pointer)...