Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?)

like image 843
miroxlav Avatar asked Mar 17 '26 04:03

miroxlav


1 Answers

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.

like image 139
Hans Passant Avatar answered Mar 18 '26 22:03

Hans Passant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!