控制台应用程序中的运行时按键检测
我使用 VC++(VS2008 Express) 开发一个 C++ 控制台应用程序。(好吧,不完全是:从控制台,另一个窗口(由第 3 方库提供,不提供任何 API 来处理图像上的按键事件)打开,其中显示我是 Windows 编程新手,我喜欢检测功能键(比如 F1)的按键并实时更改相机的一些参数,例如按下 F1 键时的亮度。我喜欢看到相机流变得更亮,我对相机 API 很满意,我不知道如何检测特定键(如功能键)的按键事件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试阅读有关 Windows 消息系统的内容。一开始您对 WM_KEYDOWN 和 WM_KEYUP 感兴趣:
http://msdn.microsoft.com/en-us/库/ms646280(VS.85).aspx
您可能需要的大多数按键检测都可以通过此 API 获得。
键码列表:http://msdn。 microsoft.com/en-us/library/dd375731(v=VS.85).aspx
如果这对您来说还不够(可能是因为您需要更多控制),请按照 DirectInput 文档进行操作(通常在“游戏”级别有用)。
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).