我使用Registerhotkey来允许我的用户定义自定义组合键来执行不同的操作。我似乎遇到的问题是,目前没有办法检查密钥是否已经存在。
例如:我的一个测试人员试图定义“Windows键+ D”,而不知道这是最小化所有窗口的组合键。因此,我很好奇是否有任何方法可以告诉我是否给定了一个组合键,以便我可以检查windows或任何其他应用程序是否已经存在该组合键。
发布于 2012-12-18 00:56:28
感谢@jim-mischel for helping me find this solution!
要检查热键是否存在,只需执行以下操作:
int ShortcutID = 100; // ID used for this Shortcut Key Combination
uint keyModifier = 2; // This is the Control Key
Char alphanumericKey = "C";
bool didItError
= RegisterHotKey(this.Handle, ShortcutID, keyModifier, (int)alphanumericKey );由于Control+C是windows注册的组合键,因此RegisterHotKey将返回false,如果不是注册组合键,它将返回true!
https://stackoverflow.com/questions/13917577
复制相似问题