Ejemplo n.º 1
0
        private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (handled)
            {
                return(IntPtr.Zero);
            }

            switch ((WM)message)
            {
            case WM.SYSCHAR:
            case WM.SYSKEYDOWN:
            case WM.SYSKEYUP:
            case WM.KEYDOWN:
            case WM.KEYUP:
            case WM.CHAR:
            case WM.IME_CHAR:
            {
                if (!IsKeyboardFocused)
                {
                    break;
                }

                if (message == (int)WM.SYSKEYDOWN &&
                    wParam.ToInt32() == KeyInterop.VirtualKeyFromKey(Key.F4))
                {
                    // We don't want CEF to receive this event (and mark it as handled), since that makes it impossible to
                    // shut down a CefSharp-based app by pressing Alt-F4, which is kind of bad.
                    return(IntPtr.Zero);
                }

                handled = managedCefBrowserAdapter.SendKeyEvent(message, wParam.ToInt32(), lParam);

                break;
            }
            }

            return(IntPtr.Zero);
        }
Ejemplo n.º 2
0
 public void SendKeyPress(int message, int wParam, CefEventFlags modifiers = CefEventFlags.None)
 {
     managedCefBrowserAdapter.SendKeyEvent(message, wParam, (int)modifiers);
 }