コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var id = ConfigurationManager.AppSettings["ImgId"];

            var img = webBrowser1.Document.GetElementById(id);

            img.InvokeMember("click");

            HTMLDocument        html  = (HTMLDocument)this.webBrowser1.Document.DomDocument;
            IHTMLControlElement img2  = (IHTMLControlElement)webBrowser1.Document.Images[id].DomElement;
            IHTMLControlRange   range = (IHTMLControlRange)((HTMLBody)html.body).createControlRange();

            range.add(img2);
            range.execCommand("Copy", false, null);

            if (Clipboard.ContainsImage())
            {
                pictureBox1.Image = Clipboard.GetImage();
            }
            else
            {
                MessageBox.Show("获取验证码失败");
            }

            Clipboard.Clear();

            pictureBox2.Image = VerificationCode.ProcessBmp(new Bitmap(pictureBox1.Image));
            textBox1.Text     = VerificationCode.Spot(new Bitmap(pictureBox1.Image), 4);
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var list = VerificationCode.SegmentBmp(new Bitmap(pictureBox2.Image));

            if (!string.IsNullOrEmpty(textBox1.Text) && list != null)
            {
                var arr = textBox1.Text.ToCharArray();
                for (int i = 0; i < arr.Length; i++)
                {
                    VerificationCode.WriteDB(arr[i].ToString(), list[i]);
                }
            }
        }
コード例 #3
0
ファイル: OfficeTool.cs プロジェクト: snoways/code-hodgepodge
        private void CheckOut2()
        {
            var txtId    = ConfigurationManager.AppSettings["TxtId"];
            var btnId    = ConfigurationManager.AppSettings["BtnCheckOutId"];
            var selectId = ConfigurationManager.AppSettings["SelectCheckInTypeId"];
            var txt      = webBrowser1.Document.GetElementById(txtId);
            var btn      = webBrowser1.Document.GetElementById(btnId);
            var select   = webBrowser1.Document.GetElementById(selectId);
            var doc      = (IHTMLDocument2)webBrowser1.Document.DomDocument;

            if (txt != null && btn != null && doc != null && select != null)
            {
                select.SetAttribute("selectedIndex", this.comboBox1.SelectedIndex.ToString());
                txt.SetAttribute("value", VerificationCode.Spot(GetVerificationImage(), 4));
                txt.InvokeMember("focus");
                btn.InvokeMember("click");
                _isCheckOuting = true;
            }
        }