Esempio n. 1
0
        public IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            bool fEatKeyStroke = false;

            var wparamTyped = wParam.ToInt32();

            if (Enum.IsDefined(typeof(VKeyState), wparamTyped))
            {
                object o = Marshal.PtrToStructure(lParam, typeof(LowLevelKeyInputArgs));
                LowLevelKeyInputArgs p = (LowLevelKeyInputArgs)o;

                var eventArguments = new GlobalKeyHookEventArgs(p, (VKeyState)wparamTyped);

                EventHandler <GlobalKeyHookEventArgs> handler = KeyboardPressed;
                handler?.Invoke(this, eventArguments);

                fEatKeyStroke = eventArguments.Handled;
            }

            return(fEatKeyStroke ? (IntPtr)1 : CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
        }
Esempio n. 2
0
 public GlobalKeyHookEventArgs(LowLevelKeyInputArgs keyboardData, VKeyState keyboardState)
 {
     KeyboardData  = keyboardData;
     KeyboardState = keyboardState;
 }