我如何检测弹出窗口是 Cefsharp 中的 PrintDialog

问题描述 投票:0回答:0

我想知道如何在 Cefsharp 中检测到 Popup 窗口是 PrintDialog,现在我在 if 子句中有这种情况,但它没有检测到 Popup 是 PrintDialog,我不知道我是否正在使用捕捉对话框的正确功能。这是我实际使用的代码:

public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
        {
            _logger.Debug($"[WebBrowser.ObjectBoundInJavascript] entered in the function successfully");
            this.popup_request?.Invoke(targetUrl);
            PrintDialog dialog = new PrintDialog();
            

            if (chromiumWebBrowser.GetFocusedFrame().GetType().Equals(dialog.GetType()))
            {
                _logger.Debug($"[WebBrowser.ObjectBoundInJavascript] It entered in the if successfully");
                //IFrame frame= chromiumWebBrowser1.GetFocusedFrame();
                //frame.ExecuteJavaScriptAsync("const event = new KeyboardEvent('keydown', 'Enter'); button.dispatchEvent(event);");
                SendKeys.Send("{ENTER}");
                _logger.Debug($"[WebBrowser.ObjectBoundInJavascript] ENTER sended successfully");
                newBrowser = null;
                return true;
            }
            _logger.Debug($"[WebBrowser.ObjectBoundInJavascript] after the if successfully");
            newBrowser = null;
            return false;
        }

谢谢 :)

就像我说的,我尝试了上面的代码,但我没有工作,如果有人能给小费,我将不胜感激。

c# winforms popup cefsharp chromium-embedded
© www.soinside.com 2019 - 2024. All rights reserved.