[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
RegisterHotKey(this.Handle, 255,1 , Keys.B);//注册快捷键alt+B 1为alt
UnregisterHotKey(this.Handle, 255);//注销
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0312:
switch (m.WParam.ToInt32())
{
case 255: /* 热键促发内容*/ break;
} break;
}
base.WndProc(ref m);
}//接受消息