I have a console application that uses GetAsyncKeyState();, but if the user is on looking at another window and pressed a button, GetAsyncKeyState(); p
To get the active Window you can call GetActiveWindow. GetFocus will return the handle of the window that has the input focus. This window can be a control as well. So you can check against your window handle and see if it has the focus.