does not go inside the Windows GetMessage loop on console application

前端 未结 2 566
你的背包
你的背包 2021-01-28 01:32

I want to detect keypress in C++ and i need to use Windows System Call. So, i did some research and this is what i got using Hooks and Message:

#include 

        
2条回答
  •  梦毁少年i
    2021-01-28 02:00

    The events are posted to the active window. Console windows are owned by the console subsystem, csrss.exe, and it receives the events, then translates them to characters and puts them in the console object which is your application's stdin.

    If you want to process events the Win32 GUI way, you should use a Win32 window (e.g. RegisterClass and CreateWindow), not a console window.

    If you just want the callbacks to work for a certain period of time, you can use an alertable wait such as SleepEx or MsgWaitForMultipleObjects, which accept a timeout.

提交回复
热议问题