Exemplo n.º 1
0
 /// <summary>
 /// Raises the KeyIntercepted event.
 /// </summary>
 /// <param name="e">An instance of KeyboardHookEventArgs</param>
 protected virtual void OnKeyIntercepted(KeyboardHookEventArgs e)
 {
     if (KeyIntercepted != null)
     {
         KeyIntercepted.Invoke(e);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the key event captured by the hook.
        /// </summary>
        private IntPtr HookCallback(
            int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
        {
            //Filter wParam for KeyUp events only
            if (nCode >= 0)
            {
                var khargs = new KeyHookEventArgs(wParam, lParam);
                var allow  = AllowKey?.Invoke(khargs) != false;

                KeyIntercepted?.Invoke(khargs, allow);

                //If this key is being suppressed, return a dummy value
                if (!allow)
                {
                    return((IntPtr)1);
                }
            }
            //Pass key to next application
            return(NativeMethods.CallNextHookEx(hookID_, nCode, wParam, ref lParam));
        }
Exemplo n.º 3
0
 public void OnKeyIntercepted(KeyboardHookEventArgs e)
 {
     KeyIntercepted?.Invoke(e);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Raises the KeyIntercepted event.
 /// </summary>
 /// <param name="e">An instance of KeyboardHookEventArgs</param>
 internal void OnKeyIntercepted(KeyboardHookEventArgs e)
 {
     KeyIntercepted?.Invoke(this, e);
 }