Esempio n. 1
0
 protected virtual void OnHookEvent(HookEventArgs hookArgs, KeyBoardInfo keyBoardInfo)
 {
     if (HookEvent != null)
     {
         HookEvent(hookArgs, keyBoardInfo);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Gets called by the system on hooked event
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        private int HookProcedure(int code, IntPtr wParam, IntPtr lParam)
        {
            KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            if (code < 0)
            {
                return(CallNextHookEx(hookDeleg, code, wParam, lParam));
            }

            // Let clients determine what to do
            HookEventArgs e = new HookEventArgs();

            e.Code   = code;
            e.wParam = wParam;
            e.lParam = lParam;

            KeyBoardInfo keyInfo = new KeyBoardInfo();

            keyInfo.vkCode   = hookStruct.vkCode;
            keyInfo.scanCode = hookStruct.scanCode;

            OnHookEvent(e, keyInfo);

            // Yield to the next hook in the chain
            return(CallNextHookEx(hookDeleg, code, wParam, lParam));
        }
Esempio n. 3
0
 protected virtual void OnHookEvent(HookEventArgs hookArgs, KeyBoardInfo keyBoardInfo)
 {
     if (HookEvent != null)
     {
         HookEvent(hookArgs, keyBoardInfo);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Gets called by the system on hooked event
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        private int HookProcedure(int code, IntPtr wParam, IntPtr lParam)
        {
            KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT));

            if (code < 0)
                return CallNextHookEx(hookDeleg, code, wParam, lParam);

            // Let clients determine what to do
            HookEventArgs e = new HookEventArgs();
            e.Code = code;
            e.wParam = wParam;
            e.lParam = lParam;

            KeyBoardInfo keyInfo = new KeyBoardInfo();
            keyInfo.vkCode = hookStruct.vkCode;
            keyInfo.scanCode = hookStruct.scanCode;

            OnHookEvent(e, keyInfo);

            // Yield to the next hook in the chain
            return CallNextHookEx(hookDeleg, code, wParam, lParam);
        }