开发者

Looking for a function similar to GetAsyncKeyState or GetCursorPos

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜