private void InvokeKeyPress(KeyPressEventArgsExt e)
 {
     KeyPressEventHandler handler = KeyPress;
     if (handler == null || e.Handled || e.IsNonChar) { return; }
     handler(this, e);
 }
        /// <summary>
        /// Creates <see cref="KeyPressEventArgsExt"/> from Windows Message parameters,
        /// based upon a system-wide hook.
        /// </summary>
        /// <param name="wParam">The first Windows Message parameter.</param>
        /// <param name="lParam">The second Windows Message parameter.</param>
        /// <returns>A new KeyPressEventArgsExt object.</returns>
        internal static KeyPressEventArgsExt FromRawDataGlobal(int wParam, IntPtr lParam)
        {
            if (wParam != Messages.WM_KEYDOWN)
            {
                return new KeyPressEventArgsExt((char)0);
            }

            KeyboardHookStruct keyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));

            int virtualKeyCode = keyboardHookStruct.VirtualKeyCode;
            int scanCode = keyboardHookStruct.ScanCode;
            int fuState = keyboardHookStruct.Flags;

            char ch;
            if ( virtualKeyCode == KeyboardNativeMethods.VK_PACKET )
            {
                ch = ( char )scanCode;
            }
            else
            {
                bool isSuccessfull = KeyboardNativeMethods.TryGetCharFromKeyboardState( virtualKeyCode, scanCode, fuState, out ch );
                if ( !isSuccessfull )
                {
                    return new KeyPressEventArgsExt( ( char )0 );
                }
            }

            KeyPressEventArgsExt e = new KeyPressEventArgsExt(ch,  keyboardHookStruct.Time);
            return e;
        }