示例#1
0
 public void setHook(bool on)
 {
     if (hooked == on)
     {
         return;
     }
     if (on)
     {
         keyBoardHandle = WindowsHookAPI.SetWindowsHookEx(WH_KEYBOARD_LL, keyBoardDelegate, IntPtr.Zero, 0);
         if (keyBoardHandle != IntPtr.Zero)
         {
             hooked = true;
         }
     }
     else
     {
         WindowsHookAPI.UnhookWindowsHookEx(keyBoardHandle);
         hooked = false;
     }
 }
 public void setHook(bool on)
 {
     if (hooked == on)
     {
         return;
     }
     if (on)
     {
         mouseHandle = WindowsHookAPI.SetWindowsHookEx(WH_MOUSE_LL, mouseDelegate, IntPtr.Zero, 0);
         if (mouseHandle != IntPtr.Zero)
         {
             hooked = true;
         }
     }
     else
     {
         WindowsHookAPI.UnhookWindowsHookEx(mouseHandle);
         hooked = false;
     }
 }