最小化应用程序时捕获媒体密钥

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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)