I'm trying to get the program to loop within a case, and stop if another case happens. So far it works ok for a couple seconds, then it freezes and crashes. It also freezes (not responding) if I click away from notepad, and try to focus my program again. All it does for now is alternate between typing '2' and '3' in notepad. I don't how to go about fixing it so the program does not "not respond" when i try to focus it while it's typing in notepad. Using Devcpp compiler
Code:
case FILE_START:
{
HWND Handle = FindWindow(NULL, "Untitled - Notepad");
if(SetForegroundWindow(Handle)){
SetFocus(Handle);
Sleep(1000);
INPUT inputf1, inputf2;
ZeroMemory(&inputf1, sizeof(INPUT));
inputf1.type = INPUT_KEYBOARD;
inputf1.ki.wVk = VK_NUMPAD2;
ZeroMemory(&inputf2,sizeof(INPUT));
inputf2.type = INPUT_KEYBOARD;
inputf2.ki.wVk = VK_NUMPAD3;
while(wParam != FILE_STOP){
Sleep(500);
SendInput(1, &inputf1, sizeof(INPUT));
Sleep(500);
SendInput(1, &inputf2, sizeof(INPUT));
}
}
}
break;