捕捉媒体键应用程序最小化时, [英] Capture Media Keys when Application is Minimized

查看:120
本文介绍了捕捉媒体键应用程序最小化时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提供一个媒体播放器我工作的媒体键,即使它的最小化工作的一个选项。什么是捕捉和处理在C#中的关键事件,而无需专注的最好方法?它甚至有可能?

I want to provide an option with a media player I'm working on for the media keys to work even when it's minimized. What's the best way to capture and process those key events in C# without having focus? Is it even possible?

推荐答案

我不认为有一个简单的方法来做到这一点,但的this(使用窗口消息来实现全球系统钩子在C#)项目可能会有帮助。
我添加下面的代码

I don't think that there is an easy way to do this but this (Using Window Messages to Implement Global System Hooks in C#) project may help. I added below code

    _GlobalHooks.Keyboard.KeyboardEvent += (w, l) => 
    {
          this.LblMouse.Text = "KEY: " + w.ToInt32().ToString("X8") + " " + l.ToInt32().ToString("X8");
    };
    _GlobalHooks.Keyboard.Start();

要GlobalHookTest的Form1的构造,并能够监控所有的键盘事件。

to the constructor of Form1 of GlobalHookTest and was able to monitor all the keyboard events.

这篇关于捕捉媒体键应用程序最小化时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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