I would like to obtain a key press signal without using ho开发者_如何学Cok or keyboard monitoring functions like getasynckeystate which seems to overkill my problem. I am in need of a function that can work globally (outside its created windows), something like GetCursorPos but for a key press (a PageUp key press) to fire some customized event. Thank you for any guidance you could offer.
I believe DirectInput can do this. A long time ago, my product team had a voice-comm app where the "push to talk" key could be caught by our app regardless if another app was in the foreground or not.
If memory server me correctly, we used DirectInput with a dedicated thread listening for DInput to signal our HEVENT handle. When the even thread woke up, it would ask directinput what key was pressed. If it was our hot key down, we unmuted the microphone (and muted it on an up event).
Most of the DirectInput docs have been take off of MSDN. (Replaced by XInput). I have no idea if xinput can accomplish the same thing. But if you can find a legacy DirectX SDK package (like DirectX 8 SDK), the docs included should have all you need for DirectInput.
精彩评论