Skip to content

Instantly share code, notes, and snippets.

@greatcodeeer
Last active August 16, 2020 09:57
Show Gist options
  • Save greatcodeeer/d6c7e94c42944b1389a9 to your computer and use it in GitHub Desktop.
Save greatcodeeer/d6c7e94c42944b1389a9 to your computer and use it in GitHub Desktop.
C# 绑定仅程序内有效的热键
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if ((Keys.Alt & keyData) == Keys.Alt) MessageBox.Show("1");
return base.ProcessCmdKey(ref msg, keyData);
}
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch (keyData)
{
case Keys.Alt | Keys.D:
MessageBox.Show("ALT+D~");
break;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment