gpt4 book ai didi

c# - 如何判断热键组合是否已经存在

转载 作者:行者123 更新时间:2023-12-04 16:50:30 25 4
gpt4 key购买 nike

我正在使用 Registerhotkey 来允许我的用户定义自定义键组合以执行不同的操作。我似乎遇到的问题是目前没有办法检查 key 是否已经存在。

例如:我的一位测试人员试图定义“Windows 键 + D”,但不知道这是最小化所有窗口的组合键。所以我很好奇是否有任何方法可以判断是否给定了一个组合键,我可以检查 Windows 或任何其他应用程序是否已经存在该组合键。

最佳答案

感谢@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!

关于c# - 如何判断热键组合是否已经存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13917577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com