Example #1
0
        public void SendKeyEvent(KeyEvent keyEvent)
        {
            if (!IsBrowserInitialized)
            {
                return;
            }

            var sendToBrowser = true;

            if (keyEvent.Type == KeyEventType.KeyUp)
            {
                if (keyEvent.Modifiers.HasFlag(CefEventFlags.ControlDown))
                {
                    if (keyEvent.WindowsKeyCode == 'C' || keyEvent.WindowsKeyCode == 'c') // ctrl + c
                    {
                        CefBrowser.GetFocusedFrame().Copy();
                        sendToBrowser = false;
                    }
                }
            }

            if (sendToBrowser)
            {
                CefBrowser.GetBrowserHost().SendKeyEvent(keyEvent);
            }
        }
Example #2
0
        public void ExecuteJS(string lines)
        {
            CefFrame frame = browser.GetFocusedFrame();
            // main frame
            if (frame.IsMain)
            {
                string base64EncodedCss = "data:text/css;charset=utf-8;base64,";
                base64EncodedCss +=
                    Convert.ToBase64String(Encoding.UTF8.GetBytes(
                        BrowserConfig.BrowserSourceSettings.CSS));

                string script = lines;
                    

                frame.ExecuteJavaScript(script,
                    null, 0);
            }

        }