Checking if a window is active

后端 未结 2 815
野性不改
野性不改 2021-01-25 11:55

I have a console application that uses GetAsyncKeyState();, but if the user is on looking at another window and pressed a button, GetAsyncKeyState(); p

2条回答
  •  再見小時候
    2021-01-25 12:37

    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");
    }
    

提交回复
热议问题