实现多媒体键盘功能 [英] Implement multimedia keyboard functions

查看:394
本文介绍了实现多媒体键盘功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以c#形式或WPF实现多媒体键盘功能,如快捷键,播放,暂停,音量,导航功能.我在使用pic微控制器的远程控制中使用了它.
该软件的工作方式类似于多媒体键盘.
如何在c#中编码多媒体功能.

解决方案

增强型键盘上的标准键在< winuser.h>中定义:

 #define VK_BROWSER_BACK 0xA6
 #define VK_BROWSER_FORWARD 0xA7
 #define VK_BROWSER_REFRESH 0xA8
 #define VK_BROWSER_STOP 0xA9
 #define VK_BROWSER_SEARCH 0xAA
 #define VK_BROWSER_FAVORITES 0xAB
 #define VK_BROWSER_HOME 0xAC

#define VK_VOLUME_MUTE 0xAD
 #define VK_VOLUME_DOWN 0xAE
 #define VK_VOLUME_UP 0xAF
 #define VK_MEDIA_NEXT_TRACK 0xB0
 #define VK_MEDIA_PREV_TRACK 0xB1
 #define VK_MEDIA_STOP 0xB2
 #define VK_MEDIA_PLAY_PAUSE 0xB3
 #define VK_LAUNCH_MAIL 0xB4
 #define VK_LAUNCH_MEDIA_SELECT 0xB5
 #define VK_LAUNCH_APP1 0xB6
 #define VK_LAUNCH_APP2 0xB7  



使用KeyDown事件并检查上述KeyCode.


工作方式将取决于您用来播放文件的内容:如果使用 Windows Media Player [远程控制媒体播放器 [

Asith 写道:

如何在C#中发送这些事件,而不是处理这些事件.



您可以使用Windows API SendInput发送它们,请参见 http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms646310%28v=vs.85%29.aspx [ 解决方案

The standard keys on the enhanced keyboards are defined in <winuser.h>:

#define VK_BROWSER_BACK 0xA6
#define VK_BROWSER_FORWARD 0xA7
#define VK_BROWSER_REFRESH 0xA8
#define VK_BROWSER_STOP 0xA9
#define VK_BROWSER_SEARCH 0xAA
#define VK_BROWSER_FAVORITES 0xAB
#define VK_BROWSER_HOME 0xAC

#define VK_VOLUME_MUTE 0xAD
#define VK_VOLUME_DOWN 0xAE
#define VK_VOLUME_UP 0xAF
#define VK_MEDIA_NEXT_TRACK 0xB0
#define VK_MEDIA_PREV_TRACK 0xB1
#define VK_MEDIA_STOP 0xB2
#define VK_MEDIA_PLAY_PAUSE 0xB3
#define VK_LAUNCH_MAIL 0xB4
#define VK_LAUNCH_MEDIA_SELECT 0xB5
#define VK_LAUNCH_APP1 0xB6
#define VK_LAUNCH_APP2 0xB7



Use the KeyDown event and check for the above KeyCodes.


How is works is going to depend on what you use to play the file: if you use a Windows Media Player[^] then it''s pretty easy, there is an article here: Remote control media player[^]


Asith wrote:

How to send these events in C#, not handle these events.



You can send them using Windows API SendInput, see http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

This is the most universal way to send input, as this function is low-level, acts as if an event is sent by a mouse or a keyboard driver, regardless to any windows, threads and other stuff. In fact, as far as I know, the drivers use this function or possibly one of obsolete functions later superseded by SendInput; using this function is also a very reliable way to solve such problems, it always works.

Good luck,

—SA


这篇关于实现多媒体键盘功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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