public static void EventCallback(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime) { desktopSwitchCnt++; if(desktopSwitchCnt == 2) { Thread.Sleep(1000); hookerDelegater.UnHook(); SendKeys.Send("{ESC}"); hookerDelegater.SetHook(); desktopSwitchCnt = 0; } }
private void KeyMouseController_FormClosing(object sender, FormClosingEventArgs e) { hooker.UnHook(); }