private void Form1_Load(object sender, EventArgs e) { k_hook = new KeyboardHook(); k_hook.KeyDownEvent += new System.Windows.Forms.KeyEventHandler(hook_KeyDown);//钩住键按下 k_hook.KeyPressEvent += K_hook_KeyPressEvent; k_hook.KeyUpEvent += K_hook_KeyUpEvent; k_hook.Start();//安装键盘钩子 if (k_hook.HookStatus == true) { toolStripTextBoxStatus.Text = "运行中"; toolStripTextBoxStatus.BackColor = Color.Green; } else { toolStripTextBoxStatus.Text = "停止中"; toolStripTextBoxStatus.BackColor = Color.Red; } }