开发者

C# global hotkey (without the usually used global hook)

I'm creating a program for my personal use that must react to some hotkeys. For example, when I press ctrl+win+z it must perform a certain action. At present, I can use GetKeyState() from user32.dll to detect the keypresses, however I am unable to stop them being passed to the active application. In the case of ctrl+win+z, the action I want to happen occurs, but if I am using explorer, for example, explorer will also read that as an 'undo'.

The obvious solution would be to use "SetWindowsHookEx()" (also from user开发者_Go百科32.dll), however each time I try a solution involving it (anything similar to this site's example code) I get a massive slow down the first time I use the hotkey. This is not acceptable.

I hope someone can help. I can provide more information if required.


Have you tried the RegisterHotKey function? It's definitely easier to use than a windows hook.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜