Search code examples
windowsconsoleraw-inputmessage-loop

Is it possible to use Windows Raw Input API without a window (ie from a console application)?


Is it possible to use Windows Raw Input API without a window (ie from a console application)?

I've tried using RegisterRawInputDevices but my message loops doesn't seem to get any events from GetMessage and hence just 'hangs' there.


Solution

  • Do you mean RegisterRawInputDevices?

    Since the RAWINPUTDEVICE structure requires you to specify an HWND to receive the WM_INPUT messages, no it's not possible to do this without a window.

    Console applications can create windows, and the window probably can receive WM_INPUT while hidden, but you do need a window.