简体   繁体   English

键盘快捷键 - 同时按下 Alt-Ctrl-Shift-D 失败

[英]Keyboard Shortcut - Simultaneous pressing Alt-Ctrl-Shift-D failes

I am using an implementation that reacts on simultaneously pressing the keys Ctrl + Alt + Shift + D meanwhile for over 2 months never having any issue.我正在使用一种实现,它对同时按下键Ctrl + Alt + Shift + D做出反应,同时超过 2 个月从来没有任何问题。 Two days ago I experienced that this short cut didn't work anymore (neither did it work on the released version, which for sure is a problem.).两天前我体验到这个捷径不再起作用了(它在发布的版本上也不起作用,这肯定是一个问题。)。 => Rebooting the PC eventually did its job and it worked again... ok... maybe (and hopefully) a spontaneous windows issue. =>重新启动PC最终完成了它的工作并且它再次工作......好吧......也许(并且希望)一个自发的windows问题。

Dream on, today the same issue again and this time rebooting didn't solve it.做梦,今天又是同样的问题,这次重启并没有解决。 So let's deal with it.所以让我们来处理它。

Here's my implementation:这是我的实现:

private void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.D
        && e.Control == true
        && e.Alt == true
        && e.Shift == true)
    {
        // do things
    }
}

As I mentioned above, it worked reliably before being used quite often.正如我上面提到的,它在经常使用之前工作可靠。

What I discovered so far is, that pressing down the keys Ctrl + Alt + Shift one by one the "MainWindow_KeyDown" function is called each time, as expected.到目前为止我发现的是,每次按下Ctrl + Alt + Shift 键,每次都会调用“MainWindow_KeyDown”function,正如预期的那样。 Pressing down the D as well this function isn't triggered anymore, which is unexpected (when only pressing D this function is called).按下D以及此 function 不再触发,这是出乎意料的(当仅按下D时,此 function 被调用)。

Removing one of the "option" keys seems to work(eg Ctrl + Alt + D ).删除“选项”键之一似乎有效(例如Ctrl + Alt + D )。 But as soon I have all three option keys pressed (ie Ctrl + Alt + Shift ) it doesn't react on further keys being pressed.但是,一旦我按下了所有三个选项键(即Ctrl + Alt + Shift ),它就不会对按下的其他键做出反应。

Why doesn't the function "MainWindow_KeyDown" react ("anymore") on D (or any other) when Ctrl + Alt + Shift are pressed already?当已经按下Ctrl + Alt + Shift时,为什么 function“MainWindow_KeyDown”对D (或任何其他)没有反应(“不再”)?

A q&d workaround was to replace q&d 解决方法是替换

e.KeyCode == Key.D

by经过

Keyboard.IsKeyDown(Key.D) == true

This works as long as D isn't the last key pressed (because, as described above, it won't enter this function when having pressed the keys Ctrl + Alt + Shift already).只要D不是按下的最后一个键(因为如上所述,当已经按下Ctrl + Alt + Shift键时,它不会输入此 function)。

I tried the following implementation as well with the same (negative) result:我也尝试了以下实现,结果相同(否定):

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if (keyData == (Keys.Control | Keys.Alt | Keys.Shift | Keys.D))
    {
        MessageBox.Show("Short cut found");
        return true;
}
    return base.ProcessCmdKey(ref msg, keyData);
}

Any one that has experienced something similar?有没有人经历过类似的事情? Thanks a lot for any input.非常感谢您的任何意见。

I had the same issue, and the following 2 steps worked for me:我遇到了同样的问题,以下两个步骤对我有用:

  1. Go to Device Manager -> Keyboards -> Right Click the keyboard(s) -> Uninstall device -> Restart the computer. Go 到设备管理器 -> 键盘 -> 右键单击键盘 -> 卸载设备 -> 重新启动计算机。
  2. Some programs are ruining this specific shortcut, in my research, i have seen people were it worked simply by closing Microsoft Teams, Cortana or Skype.一些程序正在破坏这个特定的快捷方式,在我的研究中,我看到人们只需关闭 Microsoft Teams、Cortana 或 Skype 就可以工作。 For me it worked quitting Skype.对我来说,退出 Skype 很有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM