FromRawData() static private method

Creates KeyEventArgsExt from Windows Message parameters.
static private FromRawData ( int wParam, IntPtr lParam, bool isGlobal ) : KeyEventArgsExt
wParam int The first Windows Message parameter.
lParam System.IntPtr The second Windows Message parameter.
isGlobal bool Specifies if the hook is local or global.
return KeyEventArgsExt
Ejemplo n.º 1
0
        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            KeyEventArgsExt e = KeyEventArgsExt.FromRawData(wParam, lParam, IsGlobal);

            InvokeKeyDown(e);
            InvokeKeyPress(wParam, lParam);
            InvokeKeyUp(e);

            return(!e.Handled);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            KeyEventArgsExt e = KeyEventArgsExt.FromRawData(wParam, lParam, IsGlobal);

            // not allow
            //Keys[] notAllowedKeys = {  Keys.LControlKey, Keys.RControlKey, Keys.LMenu, Keys.RMenu, Keys.LWin, Keys.RWin, Keys.Apps, Keys.Alt, Keys.Control, Keys.Tab, Keys.F1, Keys.F2, Keys.F3, Keys.F4, Keys.F5, Keys.F6, Keys.F7, Keys.F8, Keys.F9, Keys.F10, Keys.F11, Keys.F12 };

            //Steven170807
            Keys[] notAllowedKeys = { Keys.Escape, Keys.LMenu, Keys.RMenu, Keys.LWin, Keys.RWin, Keys.Apps, Keys.Alt, Keys.Control, Keys.Tab, Keys.F1, Keys.F2, Keys.F3, Keys.F4, Keys.F5, Keys.F6, Keys.F7, Keys.F8, Keys.F9, Keys.F10, Keys.F11, Keys.F12 };

            Console.WriteLine(" * Oh! : " + e.KeyData);

            //if ((Array.IndexOf(notAllowedKeys, e.KeyData) != -1) || e.Control || e.Alt || (e.Shift && e.Alt))
            if ((Array.IndexOf(notAllowedKeys, e.KeyData) != -1) || e.Alt || (e.Shift && e.Alt))
            {
                Console.WriteLine(" * Block1 : " + e.KeyData);
                return(e.Handled);
            }
            else if (e.KeyData.ToString() == "Tab, Shift" || e.KeyData.ToString() == "Shift, Tab")
            {
                // not allow modifier with tab!
                Console.WriteLine(" * Block2 : " + e.KeyData);
                return(e.Handled);
            }
            else
            {
                // for debug purpose
                string   st = e.KeyData.ToString();
                string[] s  = st.Split(',');
                Console.WriteLine("st:" + st);
                Console.WriteLine("s:" + s.Length);

                foreach (var keyData in s)
                {
                    Console.WriteLine(" * keyData : [" + keyData + "]");
                }

                // allow
                InvokeKeyDown(e);
                InvokeKeyPress(wParam, lParam);
                InvokeKeyUp(e);
                return(!e.Handled);
            }
        }