Esempio n. 1
0
 private void EmergencyPressed()
 {
     kHook.Dispose();
     mHook.Dispose();
     OpenWindow();
     MessageBox.Show(this, "Keyboard and mouse has been unhooked\r\nKey presses will not be recorded.\r\nClick \"Rehook\" to enable again", "Emergency", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         kHook?.Dispose();
     } catch { }
     try {
         kHook             = new KeyboardHook();
         kHook.KeyPressed += KeyPressed;
         kHook.Emergency  += EmergencyPressed;
     } catch (Win32Exception we) {
         Error("Hook exception", "Windows rejected keyboard hook. Try clicking \"Rehook\"\r\n" + we.Message);
     }
     try {
         mHook?.Dispose();
     } catch { }
     try {
         mHook             = new MouseHook();
         mHook.KeyPressed += MousePressed;
     } catch (Win32Exception we) {
         Error("Hook exception", "Windows rejected mouse hook. Try clicking \"Rehook\"\r\n" + we.Message);
     }
 }