如何为Windows应用程序注册自定义键盘快捷方式 [英] How to register a custom keyboard shortcut for a windows application

查看:98
本文介绍了如何为Windows应用程序注册自定义键盘快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Windows实用程序应用程序,可以使用键盘快捷键从任何其他应用程序中随时调用它,例如:

I want to create a windows utility application, which can be called anytime from within any other application using a keyboard shortcut, e.g.:

Win + T

Ctrl + T

Alt + T

Ctrl + Alt + T

Ctrl + Shift + T

我可以使用哪些组合键以及如何在Windows注册表中设置这些组合键?

(如果其他应用程序使用了该快捷方式,则它当然不起作用.)

(If the shortcut is used by an other application, it should of course not work.)

推荐答案

在应用程序启动时以编程方式执行此操作的选项是调用此Windows API:

An option for doing that programatically when your application start is calling this Windows API:

RegisterHotKey(IntPtr hwnd, int id, int fsModifiers, int vk);

要取消注册,请调用此API:

And to unregister call this API:

UnregisterHotKey(IntPtr hwnd, int id);

两者都在user32 API中存在

Both exist in user32 APIs

http://www.pinvoke.net/search.aspx?search = RegisterHotKey& namespace = [全部]

这篇关于如何为Windows应用程序注册自定义键盘快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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