c# 老板键

来源:百度知道 编辑:UC知道 时间:2024/06/15 15:53:59
c# 老板键
窗体影藏后怎么用热键呼出
this.ShowInTaskbar = false;
this.Hide();

怎么在Winform里面实现

//
[DllImport("user32.dll")]
public static extern UInt32 RegisterHotKey( IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);

//注册热键
RegisterHotKey(this.Handle, 0x3400, 1, (UInt32)Keys.Z);

//
protected override void WndProc(ref Message m)
{
const int WM_HOTKEY = 0x0312;

Console.WriteLine(m.Msg.ToString("X"));

switch(m.Msg)
{
case WM_HOTKEY:
if (m.WParam.ToInt32() == 0x3400)
{
//添加你自己的代码
Console.WriteLine("Start ...");
}
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}