Пример #1
0
        //private bool m_KillNextEvent =false;

        ///// <summary>
        ///// This one indicates that the next Key event should "die"
        ///// Used if only the customized keylistnening should be used. I.e no one else can catch the event.
        ///// </summary>
        //public bool KillNextEvent
        //{
        //    get
        //    {
        //        bool killNextEvent = m_KillNextEvent;
        //        m_KillNextEvent = false;
        //        return killNextEvent;
        //    }
        //    set
        //    {
        //        m_KillNextEvent = value;
        //    }
        //}

        private IntPtr HookCallback(int nCode, IntPtr wParam, ref HookInfo lParam)
        {
            bool keyPressed = false;
            bool signalKey  = false;

            if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN))
            {
                keyPressed = true;
                signalKey  = true;
            }
            else if (nCode >= 0 && (wParam == (IntPtr)WM_KEYUP || wParam == (IntPtr)WM_SYSKEYUP))
            {
                keyPressed = false;
                signalKey  = true;
            }
            Debug.WriteLine("wParam = " + wParam.ToString() + " - vkCode = " + lParam.vkCode.ToString(CultureInfo.InvariantCulture) + " - flags = " + lParam.flags.ToString(CultureInfo.InvariantCulture));

            if (signalKey)
            {
                AddKeySignals(lParam.vkCode, keyPressed);
            }

            IntPtr nextHook;

            //if (KillNextEvent)
            //{
            //    nextHook = (IntPtr)1;
            //}
            //else
            //{
            nextHook = CallNextHookEx(m_HookId, nCode, wParam, ref lParam);
            //}

            //if (signalKey)
            //{
            //    AddKeySignals(lParam.vkCode, keyPressed);
            //}
            return(nextHook);
        }
Пример #2
0
 private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, ref HookInfo lParam);