Cannot catch Ctrl+Alt+F1 in WinForms MDI. Is it special?

流过昼夜 提交于 2019-12-10 21:48:59

问题


My WinForms MDI application has several keyboard shortcuts set at ToolStripMeniItem items.

Among the following ones:

  • Ctrl+Alt+F1
  • Ctrl+Alt+F2
  • Ctrl+Alt+F3

the first one is never triggering its menu item. Others work as expected.

  • Is it somewhere blocked/used? Is there some list of such blocked keyboard shortcuts?

  • Is there a way how to use it? (Preferably just via designer without adding special code?)


回答1:


If I press Ctrl+Alt+F1 on my machine then it activates the "Intel HD Graphics Control Panel". A pretty well spread piece of useless malware that many machines have pre-installed, Intel is very irresponsible with their software. When I kill the igfxHK.exe process with Task Manager (HK = Hot Key) then this code in a MDI app works fine:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
        Console.WriteLine((int)keyData);
        if (keyData == (Keys.F1 | Keys.Control | Keys.Alt)) {
            MessageBox.Show("Yada");
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

I'll spare you the "Yada" screenshot. Otherwise a pretty typical hazard, programs that call RegisterHotKey() always get ahead of your shortcut keystroke and do whatever they are supposed to do. The Language Bar jumps to mind as another one. There are many others. Kill processes with Task Manager to find the evil-doer.

Not much you can do about it of course. You can run msconfig.exe to disable it but that doesn't do anything useful for your user's machine. These programs invariably pick the obvious keys, you could counteract by picking your shortcut keys from right to left. Best thing is to avoid keys that require more than one modifier, a user doesn't like them either.



来源:https://stackoverflow.com/questions/28649734/cannot-catch-ctrlaltf1-in-winforms-mdi-is-it-special

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!