コード例 #1
0
        private void ShowDialog(IHTMLElement el)
        {
            cEXWB webBrowser = AppContext.Browser as cEXWB;

            if (webBrowser.InvokeRequired)
            {
                webBrowser.Invoke(new Action(Perform));
                return;
            }
            ValidateCodeDialog dialog = new ValidateCodeDialog(webBrowser, el);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                InputValue = dialog.ValidateCode;
            }
        }
コード例 #2
0
        public override void Perform()
        {
            cEXWB webBrowser = AppContext.Browser as cEXWB;

            if (webBrowser.InvokeRequired)
            {
                webBrowser.Invoke(new Action(Perform));
                return;
            }
            bool exists = Window.Elements.Exists(GetConstraint());

            if (exists)
            {
                Element element = GetElement();
                //弹出对话框输验证码
                if (ValidateImage != null && !string.IsNullOrEmpty(ValidateImage.InputValue))
                {
                    TextToType = ValidateImage.InputValue;
                    base.Perform();
                }
                else if (IsMobileValidate)
                {
                    ValidateCodeDialog dialog = new ValidateCodeDialog(webBrowser);
                    dialog.Activate();
                    dialog.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (!string.IsNullOrEmpty(dialog.ValidateCode))
                        {
                            TextToType = dialog.ValidateCode;
                            base.Perform();
                        }
                    }
                }
                else //在浏览器里面输验证码
                {
                    //var nativeElement = element.NativeElement as IEElement;
                    //nativeElement.AsHtmlElement.scrollIntoView();
                    //webBrowser.WBKeyDown -= new WBKeyDownEventHandler(webBrowser_WBKeyDown);
                    //webBrowser.WBKeyDown += new WBKeyDownEventHandler(webBrowser_WBKeyDown);
                    //this.Breakpoint = BreakpointIndicators.ActiveBreakpoint;
                }
            }
        }