I have a Win32 program that runs on a loop. I would like to be able to pause that program while awaiting a keypress. It doesn\'t matter whether I use \'any key\' or a specif
HWND hwnd = ::GetConsoleWindow(); while (!((::GetForegroundWindow() == hwnd) && ((::GetKeyState(VK_SPACE) & 0x8000) != 0))) ::Sleep(0);
Suppose it is not the best way but it solved my problem. Replace VK_SPACE with any other value you like. And it is not portable.