控制台应用程序中的运行时按键检测 [英] Runtime keypress detection in a console application

查看:113
本文介绍了控制台应用程序中的运行时按键检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VC ++(VS2008 Express)开发C ++控制台应用程序.(嗯,不完全是:从控制台,另一个窗口(由第3方库提供,该库未提供任何API来处理图像上的按键事件).它显示了一个摄像机流.我是Windows编程的新手,我想检测功能键的按键(让我们说F1)并实时更改摄像机的某些参数(例如其亮度),也就是说,当F1键处于按下,id希望看到摄像头流变得更亮.我对摄像头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.

推荐答案

尝试阅读有关Windows消息系统的信息.一开始,您对WM_KEYDOWN和WM_KEYUP感兴趣: http://msdn.microsoft.com/en-us/库/ms646280(VS.85).aspx 您可能需要的大多数按键检测都可以通过此API获得.

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.

键代码列表: http://msdn.microsoft.com/zh-CN/library/dd375731(v=VS.85).aspx

如果这对您来说还不够(也许是因为您需要更多控制权),那么请阅读DirectInput文档(通常在游戏"级别有用).

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

这篇关于控制台应用程序中的运行时按键检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆