在C#中解决全局热键处理的最佳方式? [英] Best way to tackle global hotkey processing in c#?

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

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/48935/how-can-i-register-a-global-hot-key-to-say-ctrlshiftletter-using-wpf-and-ne\">How我可以注册一个全局热键说CTRL + SHIFT +使用WPF和.NET 3.5(LETTER)?

我想有多个全局热键在我的新的应用程序(控制从窗户任何地方的应用程序),以及所有给定的来源/解决方案,我发现在网络上似乎有一个排序一瘸一拐的解决方案提供(无论是解决方案只为一个g.hotkey,或解决方案,同时运行在屏幕上创建恼人的鼠标延时)。

I'd like to have multiple global hotkeys in my new app (to control the app from anywhere in windows), and all of the given sources/solutions I found on the web seem to provide with a sort of a limping solution (either solutions only for one g.hotkey, or solutions that while running create annoying mouse delays on the screen).

在这里有谁知道一种资源,可以帮助我achive这一点,我可以借鉴?
什么?

Does anyone here know of a resource that can help me achive this, that I can learn from? Anything?

谢谢! :)

推荐答案

我已经找到了最好的解决方案是<一个href=\"http://bloggablea.word$p$pss.com/2007/05/01/global-hotkeys-with-net/\">http://bloggablea.word$p$pss.com/2007/05/01/global-hotkeys-with-net/

The nicest solution I've found is http://bloggablea.wordpress.com/2007/05/01/global-hotkeys-with-net/

Hotkey hk = new Hotkey();

hk.KeyCode = Keys.1;
hk.Windows = true;
hk.Pressed += delegate { Console.WriteLine("Windows+1 pressed!"); };

hk.Register(myForm); 

请注意如何设置不同的lambda表达式到不同的热键

Note how you can set different lambdas to different hotkeys

这篇关于在C#中解决全局热键处理的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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