Pause program til press key
Hey guys i know its a little noob but i want to when a key is pressed program pause and when pressed other continue can u guys help?
Like if(GetAsyncKeyStateK(VK_LMENU)) It pauses now and when
if(GetAsyncKeyState(VK_SHIFT)) It continues =).
What program are you making ?
You can do something like this:
[highlight=c++]
if(GetAsyncKeyState(VK_SPACE))
{
//Simulate a key press; although it is not needed if you use _getch();
keybd_event(VK_SPACE, 0, 0, 0);
//Wait for half a second.
Sleep(500);
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
}
[/highlight]
Though I don't understand the purpose of that. You can just use _getch(); which waits for the user to press any key to continue the execution of program. Also, pressing shift doesn't do shit, so you got to use some other key. I used space.