Winfroms检测组合键

首先设置KeyPreview = true;

Ctrl+V

if (e.Modifiers == Keys.Control && e.KeyCode == Keys.V)
{
    MessageBox.Show("Test");
}

Ctrl+Alt+B

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.Alt)
    {
        if (e.KeyCode == Keys.B)
        {
            // Your code goes here
        }
    }
}

Ctrl+H+E

Keys lstKeyPressed;

private void Form1_KeyDown(object sender, KeyEventArgs e)
{

    if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.E && lstKeyPressed == Keys.H)
    {
        Console.WriteLine("Ctrl+H+E");// 仅实现Ctrl+H+E,Ctrl+E+H不触发
    }

    lstKeyPressed = e.KeyCode;
}

Winfroms检测组合键

上一篇:Qt 显示一个窗体,show()函数和exec()函数有什么区别?


下一篇:Windows批处理命令学习