我必须将代码跟到capture keys pressed:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
int x;
switch (keyData)
{
case (Keys)131149: //case Keys.Control | Keys.M:
x = 1;
break;
case Keys.Alt | Keys.Z:
x = 2;
break;
case Keys.Shift | Keys.A:
x = 3;
break;
case (Keys)196685: //Keys.Control | Keys.Shift | Keys.M:
x = 1;
break;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
你可以看到按键组合 Ctrl + Shift + M == 196685.
我有没有办法在我的代码中计算其他组合?
例如: Alt + F ==?等...
答案 0 :(得分:2)
Console.Write((int)(Keys.Alt | Keys.F))
或更基本的:
1000000000000000000 OR 1000110 = 1000000000001000110