全球键盘捕获在C#中的应用键盘、全球

2023-09-02 01:18:22 作者:喂,莪爱迩。

我想捕捉在我的应用程序中的键盘快捷键,并触发一个对话框,如果用户presses键盘组合连外应用程序的出现。类似谷歌桌面搜索的Ctrl键,Ctrl键,弹出搜索对话框。

I want to capture a keyboard shortcut in my application and trigger a dialog to appear if the user presses a keyboard combo even outside of the app. Similar to Google Desktop Search's Ctrl, Ctrl to bring up the search dialog.

我已经使用了一些键盘钩子模块,在那里,基本上用的Win32互操作来获得这种效果尝试,但每种实现我试着联系下键盘在一定程度上,你开始变得怪异行为时,该应用程序是做一些密集。例如装载大量的数据,这会导致键盘和鼠标锁死。

I have tried using some keyboard hook modules out there that basically use Win32 interop to get this effect but each implementation I've tried ties down the keyboard to some extent to where you start getting weird behaviors when the application is doing something intensive. Such as loading a large amount of data, this would cause the keyboard and mouse to lockup.

我正在寻找一个轻量级的解决方案,将允许这是不绑下来的键盘和鼠标完成的。

I'm looking for a lightweight solution that would allow this to be done without tying down the keyboard and mouse.

推荐答案

斯蒂芬Toub 写在C#中实施全球键盘钩子一大篇。

约翰