在WPF全局热键? [英] Global hotkeys in WPF?

查看:146
本文介绍了在WPF全局热键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立一个WPF应用程序,并要添加全局热键支持。 我希望能够在我的应用程序从任何地方在窗口中执行的方法,即使在我的应用程序最小化或托盘上运行。例如,使用Ctrl + Alt + T执行的方法。

I've build a WPF application and want to add global hotkey support. I want to be able to execute a method in my application from anywhere in windows, even when my application is minimized or running in tray. For example, execute the method with ctrl + alt + t.

这是可能的WPF,如果是的话,怎么办?

Is this possible in WPF, and if so, how?

推荐答案

您需要看一看RegisterHotKey user32.dll中。下面是在pinvoke.net一个很好的例子: http://www.pinvoke.net/ Default.aspx的/ USER32 / RegisterHotKey.html

You need to take a look at RegisterHotKey in user32.dll. Here's a good example at pinvoke.net: http://www.pinvoke.net/default.aspx/user32/RegisterHotKey.html

这篇关于在WPF全局热键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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