Last active
August 16, 2020 09:57
-
-
Save greatcodeeer/d6c7e94c42944b1389a9 to your computer and use it in GitHub Desktop.
C# 绑定仅程序内有效的热键
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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