Runtime keypress detection in a console application

╄→гoц情女王★ 提交于 2019-12-13 01:53:09

问题


I use VC++(VS2008 Express) to develop a C++ console application.(well, not exactly: from the console,another window(provided by 3rd party library which does not provide any API to process keypress events on the image) opens which displays a camera stream. I am new to windows programming. I like to detect the keypress of the function key(lets say F1) and change some parameters of the camera like its brightness in real time, that is, when the F1 key is pressed, i d like to see the camera stream getting brighter. I am comfortable with the camera API. That part will be OK, what i dont know is how to detect the keypress events of a specific key like the function key.


回答1:


Try reading about windows message system. You are interested in WM_KEYDOWN and WM_KEYUP as for the beginning: http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx Most of key-press detection you may need is available through this API.

The key-codes list: http://msdn.microsoft.com/en-us/library/dd375731(v=VS.85).aspx

If this is not enough for you (maybe because you need more control), then follow to DirectInput documentation (generally useful at "gaming" level).



来源:https://stackoverflow.com/questions/6897058/runtime-keypress-detection-in-a-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!