Ejemplo n.º 1
0
 static IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, ref Native.KBDLLHOOKSTRUCT lParam)
 {
     bool cancel = false;
     if(nCode == Native.HC_ACTION) {
         KeybordCaptureEventArgs e = new KeybordCaptureEventArgs(lParam);
         switch(wParam.ToInt32()) {
             case Native.WM_KEYDOWN:
                 if(KeyDown != null)
                     KeyDown(null, e);
                 break;
             case Native.WM_KEYUP:
                 if(KeyUp != null)
                     KeyUp(null, e);
                 break;
             case Native.WM_SYSKEYDOWN:
                 if(SysKeyDown != null)
                     SysKeyDown(null, e);
                 break;
             case Native.WM_SYSKEYUP:
                 if(SysKeyUp != null)
                     SysKeyUp(null, e);
                 break;
         }
         cancel = e.Cancel;
     }
     return cancel ? (IntPtr)1 : Native.CallNextHookEx(s_hook, nCode, wParam, ref lParam);
 }
Ejemplo n.º 2
0
        private static IntPtr HookProc(int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
        {
            bool cancel = false;

            if (nCode == HC_ACTION)
            {
                KeybordCaptureEventArgs ev = new KeybordCaptureEventArgs(lParam);
                switch (wParam.ToInt32())
                {
                case WM_KEYDOWN:
                    CallEvent(KeyDown, ev);
                    break;

                case WM_KEYUP:
                    CallEvent(KeyUp, ev);
                    break;

                case WM_SYSKEYDOWN:
                    CallEvent(SysKeyDown, ev);
                    break;

                case WM_SYSKEYUP:
                    CallEvent(SysKeyUp, ev);
                    break;
                }
                cancel = ev.Cancel;
            }
            return(cancel ? (IntPtr)1 : CallNextHookEx(s_hook, nCode, wParam, ref lParam));
        }
Ejemplo n.º 3
0
 private static void CallEvent(EventHandler <KeybordCaptureEventArgs> eh, KeybordCaptureEventArgs ev)
 {
     if (eh != null)
     {
         eh(null, ev);
     }
 }
Ejemplo n.º 4
0
        static IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, ref Native.KBDLLHOOKSTRUCT lParam)
        {
            bool cancel = false;

            if (nCode == Native.HC_ACTION)
            {
                KeybordCaptureEventArgs e = new KeybordCaptureEventArgs(lParam);
                switch (wParam.ToInt32())
                {
                case Native.WM_KEYDOWN:
                    if (KeyDown != null)
                    {
                        KeyDown(null, e);
                    }
                    break;

                case Native.WM_KEYUP:
                    if (KeyUp != null)
                    {
                        KeyUp(null, e);
                    }
                    break;

                case Native.WM_SYSKEYDOWN:
                    if (SysKeyDown != null)
                    {
                        SysKeyDown(null, e);
                    }
                    break;

                case Native.WM_SYSKEYUP:
                    if (SysKeyUp != null)
                    {
                        SysKeyUp(null, e);
                    }
                    break;
                }
                cancel = e.Cancel;
            }
            return(cancel ? (IntPtr)1 : Native.CallNextHookEx(s_hook, nCode, wParam, ref lParam));
        }
		static IntPtr HookProc(int nCode, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
		{
			bool cancel = false;
			if (nCode == HC_ACTION)
			{
				KeybordCaptureEventArgs ev = new KeybordCaptureEventArgs(lParam);
				switch (wParam.ToInt32())
				{
					case WM_KEYDOWN:
						CallEvent(KeyDown, ev);
						break;

					case WM_KEYUP:
						CallEvent(KeyUp, ev);
						break;

					case WM_SYSKEYDOWN:
						CallEvent(SysKeyDown, ev);
						break;

					case WM_SYSKEYUP:
						CallEvent(SysKeyUp, ev);
						break;
				}
				cancel = ev.Cancel;
			}
			return cancel ? (IntPtr)1 : CallNextHookEx(s_hook, nCode, wParam, ref lParam);
		}
		private static void CallEvent(EventHandler<KeybordCaptureEventArgs> eh, KeybordCaptureEventArgs ev)
		{
			if (eh != null)
				eh(null, ev);
		}