Capture Media Keys when Application is Minimized(最小化应用程序时捕获媒体密钥)
问题描述
我想为我正在开发的媒体播放器提供一个选项,以使媒体键即使在最小化时也能正常工作.在没有焦点的情况下在 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?
推荐答案
我不认为有一个简单的方法可以做到这一点,但 这个(使用窗口消息在 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.
这篇关于最小化应用程序时捕获媒体密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:最小化应用程序时捕获媒体密钥
基础教程推荐
- WPF 模态进度窗口 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
