I have a console application that uses GetAsyncKeyState();, but if the user is on looking at another window and pressed a button, GetAsyncKeyState(); p
GetAsyncKeyState();
This thing worked for me:
HWND name; name=GetForegroundWindow(); while(!_kbhit()){ if(name==GetForegroundWindow()) printf("Mine window is active\n"); else printf("Mine window is not active\n"); }