private void hook_KeyHookEvent(object sender, KeyHook.KeyHookEventArgs e) { switch (e.KBParam.scanCode) { case 0: //key 0 if (e.Flag == KeyHook.WM_KEYDOWN) { SendKeys.Sends(SendKeys.VK_ESCAPE, SendKeys.KEYEVENTF_KEYDOWN); } else if (e.Flag == KeyHook.WM_KEYUP) { SendKeys.Sends(SendKeys.VK_ESCAPE, SendKeys.KEYEVENTF_KEYUP); } break; case 1: if (e.Flag == KeyHook.WM_KEYDOWN) { SendKeys.Sends(SendKeys.VK_UP, SendKeys.KEYEVENTF_KEYDOWN); } else if (e.Flag == KeyHook.WM_KEYUP) { SendKeys.Sends(SendKeys.VK_UP, SendKeys.KEYEVENTF_KEYUP); } break; case 2: if (e.Flag == KeyHook.WM_KEYDOWN) { SendKeys.Sends(SendKeys.VK_RETURN, SendKeys.KEYEVENTF_KEYDOWN); } else if (e.Flag == KeyHook.WM_KEYUP) { SendKeys.Sends(SendKeys.VK_RETURN, SendKeys.KEYEVENTF_KEYUP); } break; case 3: if (e.Flag == KeyHook.WM_KEYDOWN) { SendKeys.Sends(SendKeys.VKSCAN, SendKeys.KEYEVENTF_KEYDOWN); if (!(ActivedForm is FrRead)) { if (GVars.Utility.FindShutdownForm() != IntPtr.Zero) { return; } if (ActivedForm != null && !(ActivedForm is FrMain)) { ActivedForm.Close(); } if (ParentForm is FrMain) { FrMain pa = (FrMain)ParentForm; pa.ShowXunjian(); } } } else if (e.Flag == KeyHook.WM_KEYUP) { SendKeys.Sends(SendKeys.VKSCAN, SendKeys.KEYEVENTF_KEYUP); } break; case 4: if (e.Flag == KeyHook.WM_KEYDOWN) { SendKeys.Sends(SendKeys.VK_DOWN, SendKeys.KEYEVENTF_KEYDOWN); } else if (e.Flag == KeyHook.WM_KEYUP) { SendKeys.Sends(SendKeys.VK_DOWN, SendKeys.KEYEVENTF_KEYUP); } break; } if (e.Flag == KeyHook.WM_KEYDOWN) { SetWindowFocus(); } }