コード例 #1
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void subimt(String URL, SubmitPrice points, CaptchaInput inputType)
        {
            logger.WarnFormat("BEGIN 验证码({0})", inputType);

            ScreenUtil.SetCursorPos(points.inputBox.x, points.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            logger.Info("\tBEGIN make INPUTBOX blank");
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            logger.Info("\tEND   make INPUTBOX blank");

            byte[] content = new ScreenUtil().screenCaptureAsByte(points.captcha[0].x, points.captcha[0].y, 128, 28);
            byte[] binaryTips = new ScreenUtil().screenCaptureAsByte(points.captcha[1].x, points.captcha[1].y, 112, 16);
            Bitmap bitmap = new Bitmap(new MemoryStream(content));
            this.pictureBox1.Image = bitmap;
            String strLoading = this.m_orcCaptchaLoading.IdentifyStringFromPic(bitmap);
            logger.InfoFormat("LOADING : {0}", strLoading);

            //if ("正在获取校验码".Equals(strLoading)) {
            //    logger.InfoFormat("正在获取校验码,关闭&打开窗口重新获取");
            //    ScreenUtil.SetCursorPos(points.buttons[0].x + 188, points.buttons[0].y);//取消按钮
            //    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            //    return;
            //}

            logger.Info("\tBEGIN identify Captcha");
            String txtCaptcha = this.m_orcCaptcha.IdentifyStringFromPic(bitmap);
            logger.InfoFormat("\tEND   identify Captcha : [{0}]", txtCaptcha);

            logger.Info("\tBEGIN input ACTIVE CAPTCHA");
            String strActive = "";
            if (CaptchaInput.LEFT == inputType)
                strActive = txtCaptcha.Substring(0, 4);
            else if (CaptchaInput.MIDDLE == inputType)
                strActive = txtCaptcha.Substring(1, 4);
            else if (CaptchaInput.RIGHT == inputType)
                strActive = txtCaptcha.Substring(2, 4);
            else if (CaptchaInput.AUTO == inputType)
                strActive = this.m_orcCaptchaTipsUtil.getActive(txtCaptcha, new Bitmap(new MemoryStream(binaryTips)));

            for (int i = 0; i < strActive.Length; i++) {
                ScreenUtil.keybd_event(ScreenUtil.keycode[strActive[i].ToString()], 0, 0, 0);
                ScreenUtil.keybd_event(ScreenUtil.keycode[strActive[i].ToString()], 0, 0x2, 0);
                System.Threading.Thread.Sleep(25);
            }
            logger.InfoFormat("\tEND   input ACTIVE CAPTCHA [{0}]", strActive);

            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult dr = MessageBox.Show("确定要提交出价吗?", "提交出价", messButton, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                if (dr == DialogResult.OK) {
                    logger.Info("用户选择确定出价");
                    ScreenUtil.SetCursorPos(points.buttons[0].x, points.buttons[0].y);//确定按钮
                    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

                    System.Threading.Thread.Sleep(1000);
                    ScreenUtil.SetCursorPos(points.buttons[0].x + 188 / 2, points.buttons[0].y - 10);//确定按钮
                    //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                } else {
                    logger.Warn("用户选择取消出价");
                    ScreenUtil.SetCursorPos(points.buttons[0].x + 188, points.buttons[0].y);//取消按钮
                    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                }
            }
            logger.Info("END   验证码");
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void button_checkTips_Click(object sender, EventArgs e)
        {
            foreach (PictureBox picBox in this.pictureSubs)
                picBox.Image = null;

            String[] pos = this.textPosition.Text.Split(new char[] { ',' });
            byte[] content = new ScreenUtil().screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 140, 24);
            this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));

            this.label2.Text = this.m_orcCaptchaTipsUtil.getActive("一二三四五六", new Bitmap(new MemoryStream(content)));
            for (int i = 0; i < this.m_orcCaptchaTipsUtil.SubImgs.Count; i++)
                this.pictureSubs[i].Image = this.m_orcCaptchaTipsUtil.SubImgs[i];
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void givePrice(String URL, GivePriceStep2 points, int deltaPrice)
        {
            logger.WarnFormat("BEGIN 出价格(delta : {0})", deltaPrice);
            byte[] content = new ScreenUtil().screenCaptureAsByte(points.price.x, points.price.y, 52, 18);
            this.pictureBox2.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));
            logger.Info("\tBEGIN identify Price");
            String txtPrice = this.m_orcPrice.IdentifyStringFromPic(new Bitmap(this.pictureBox2.Image));
            logger.InfoFormat("\tEND  identify Price : {0}", txtPrice);
            int price = Int32.Parse(txtPrice);
            price += deltaPrice;
            txtPrice = String.Format("{0:D5}", price);

            logger.InfoFormat("\tBEGIN input PRICE : {0}", txtPrice);
            ScreenUtil.SetCursorPos(points.inputBox.x, points.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);

            for (int i = 0; i < txtPrice.Length; i++) {
                System.Threading.Thread.Sleep(25);
                ScreenUtil.keybd_event(ScreenUtil.keycode[txtPrice[i].ToString()], 0, 0, 0);
                ScreenUtil.keybd_event(ScreenUtil.keycode[txtPrice[i].ToString()], 0, 0x2, 0);
            }
            logger.Info("\tEND   input PRICE");

            //点击出价
            System.Threading.Thread.Sleep(100);
            logger.Info("\tBEGIN click button[出价]");
            ScreenUtil.SetCursorPos(points.button.x, points.button.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            logger.Info("\tEND   click button[出价]");
            logger.Info("END   出价格");
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void button_checkCaptcha_Click(object sender, EventArgs e)
        {
            foreach (PictureBox picBox in this.pictureSubs)
                picBox.Image = null;

            String[] pos = this.textPosition.Text.Split(new char[] { ',' });
            byte[] content = new ScreenUtil().screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 120, 38);
            this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));

            if (this.checkBoxCaptcha.Checked) {//如果选中“校验码”

                //String strCaptcha = new HttpUtil().postByteAsFile(this.textURL.Text + "/receive/captcha/detail.do", content);
                String strCaptcha = this.m_orcCaptcha.IdentifyStringFromPic(new Bitmap(new MemoryStream(content)));
                //String[] array = Newtonsoft.Json.JsonConvert.DeserializeObject<String[]>(strCaptcha);

                for (int i = 0; i < 6; i++)
                    this.pictureSubs[i].Image = this.m_orcCaptcha.SubImgs[i];
                this.label1.Text = strCaptcha;

            } else {//测试“正在加载校验码”

                String strLoading = this.m_orcCaptchaLoading.IdentifyStringFromPic(new Bitmap(new System.IO.MemoryStream(content)));

                for (int i = 0; i < 6; i++)
                    this.pictureSubs[i].Image = this.m_orcCaptchaLoading.SubImgs[i];
                this.label2.Text = strLoading;
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void button_checkPrice_Click(object sender, EventArgs e)
        {
            foreach (PictureBox picBox in this.pictureSubs)
                picBox.Image = null;

            String[] pos = this.textPosition.Text.Split(new char[] { ',' });
            byte[] content = new ScreenUtil().screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 100, 24);
            this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));
            String txtPrice = this.m_orcPrice.IdentifyStringFromPic(new Bitmap(this.pictureBox3.Image));
            for (int i = 0; i < this.m_orcPrice.SubImgs.Count; i++)
                this.pictureSubs[i].Image = this.m_orcPrice.SubImgs[i];
            this.label1.Text = txtPrice;
        }
コード例 #6
0
ファイル: SchedulerJob.cs プロジェクト: CapricornZ/autobid
        /// <summary>
        /// 获取当前价格,+delta,出价
        /// </summary>
        /// <param name="givePrice">坐标</param>
        /// <param name="delta">差价</param>
        private void givePrice(GivePrice givePrice, int delta)
        {
            logger.Info("BEGIN givePRICE");
            logger.Info("\tBEGIN identify PRICE...");
            byte[] content = new ScreenUtil().screenCaptureAsByte(givePrice.price.x, givePrice.price.y, 52, 18);
            String txtPrice = this.m_orcPrice.getCharFromPic(new Bitmap(new System.IO.MemoryStream(content)));
            int price = Int32.Parse(txtPrice);
            price += delta;
            txtPrice = String.Format("{0:D}", price);
            logger.InfoFormat("\tEND   identified PRICE = %s", txtPrice);

            //INPUT BOX
            logger.InfoFormat("\tBEGIN input PRICE : {0}", txtPrice);
            ScreenUtil.SetCursorPos(givePrice.inputBox.x, givePrice.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);

            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);

            for (int i = 0; i < txtPrice.Length; i++)
            {
                System.Threading.Thread.Sleep(50);
                ScreenUtil.keybd_event(ScreenUtil.keycode[txtPrice[i].ToString()], 0, 0, 0);
            }
            logger.Info("\tEND   input PRICE");

            //点击出价
            logger.Info("\tBEGIN click BUTTON[出价]");
            System.Threading.Thread.Sleep(50);
            ScreenUtil.SetCursorPos(givePrice.button.x, givePrice.button.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            logger.Info("\tEND   click BUTTON[出价]");
            logger.Info("END   givePRICE");
        }
コード例 #7
0
ファイル: SchedulerJob.cs プロジェクト: CapricornZ/autobid
        private Boolean submit(String URL, SubmitPrice submitPoints)
        {
            logger.Info("BEGIN giveCAPTCHA");
            logger.Info("\tBEGIN make INPUT blank");
            ScreenUtil.SetCursorPos(submitPoints.inputBox.x, submitPoints.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);

            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            logger.Info("\tEND   make INPUT blank");

            logger.Info("\tBEGIN identify CAPTCHA...");
            byte[] binaryCaptcha = null;
            Boolean isLoading = true;
            int retry = 0;
            while (isLoading)
            {
                logger.InfoFormat("\t try LOADING = {0}", retry++);
                binaryCaptcha = new ScreenUtil().screenCaptureAsByte(submitPoints.captcha[0].x, submitPoints.captcha[0].y, 128, 28);
                String strLoading = this.m_orcLoading.getCharFromPic(new Bitmap(new MemoryStream(binaryCaptcha)));
                logger.InfoFormat("\t LOADING = {0}", strLoading);
                if ("正在获取校验码".Equals(strLoading))
                {
                    if (retry > 2)
                    {//重试0,1,2,3都在获取校验码
                        logger.InfoFormat("Abort,close & re-open");
                        ScreenUtil.SetCursorPos(submitPoints.buttons[0].x+188, submitPoints.buttons[0].y);//取消按钮
                        ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                        return false;//放弃本次出价
                    }
                    Thread.Sleep(250);
                }
                else
                    isLoading = false;
            }

            logger.Info("\t\tBEGIN post CAPTACH");
            String txtCaptcha = new HttpUtil().postByteAsFile(URL + "/receive/captcha.do", binaryCaptcha);
            logger.Info("\t\tEND   post CAPTACH");
            byte[] binaryTips = new ScreenUtil().screenCaptureAsByte(submitPoints.captcha[1].x, submitPoints.captcha[1].y, 112, 16);
            String strActive = this.m_captchaUtil.getActive(txtCaptcha, new Bitmap(new System.IO.MemoryStream(binaryTips)));
            logger.InfoFormat("\tEND   identified CAPTCHA = {0}, ACTIVE = {1}", txtCaptcha, strActive);

            logger.Info("\tBEGIN input CAPTCHA");
            {
                for (int i = 0; i < strActive.Length; i++)
                {
                    ScreenUtil.keybd_event(ScreenUtil.keycode[strActive[i].ToString()], 0, 0, 0);
                    System.Threading.Thread.Sleep(50);
                }
            }
            logger.Info("\tEND   input CAPTCHA");

            logger.Info("\tBEGIN click BUTTON[确定]");
            ScreenUtil.SetCursorPos(submitPoints.buttons[0].x, submitPoints.buttons[0].y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            logger.Info("\tEND   click BUTTON[确定]");

            ScreenUtil.SetCursorPos(submitPoints.buttons[0].x + 188 / 2, submitPoints.buttons[0].y - 10);//确定按钮

            //System.Threading.Thread.Sleep(3000);
            //if (points.Length > 2)
            //{
            //    System.Threading.Thread.Sleep(50);
            //    ScreenUtil.SetCursorPos(points[2].X, points[2].Y);
            //    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            //    if (points.Length > 3)
            //    {
            //        System.Threading.Thread.Sleep(50);
            //        ScreenUtil.SetCursorPos(points[3].X, points[3].Y);
                    //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            //    }
            //}
            logger.Info("END   giveCAPTCHA");
            return true;
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: CapricornZ/autobid
        private void subimt(String URL, SubmitPrice points, int type)
        {
            logger.Info("BEGIN 验证码");
            ScreenUtil.SetCursorPos(points.inputBox.x, points.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            logger.Info("\tBEGIN make INPUTBOX blank");
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0);

            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            System.Threading.Thread.Sleep(50); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0);
            logger.Info("\tEND   make INPUTBOX blank");

            byte[] content = new ScreenUtil().screenCaptureAsByte(points.captcha[0].x, points.captcha[0].y, 128, 28);
            this.pictureBox1.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));
            String strLoading = this.m_orcCaptchaLoading.getCharFromPic(new Bitmap(new MemoryStream(content)));
            logger.InfoFormat("LOADING : {0}", strLoading);
            if ("正在获取校验码".Equals(strLoading))
            {
                logger.InfoFormat("正在获取校验码,关闭&打开窗口重新获取");
                ScreenUtil.SetCursorPos(points.buttons[0].x+188, points.buttons[0].y);//取消按钮
                ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                return;
            }

            //byte[] content = null;
            //Boolean isLoading = true;
            //int retry = 0;
            //while (isLoading)
            //{
            //    content = new ScreenUtil().screenCaptureAsByte(points.captcha[0].x, points.captcha[0].y, 128, 28);
            //    String strLoading = this.m_orcCaptchaLoading.getCharFromPic(new Bitmap(new MemoryStream(content)));
            //    logger.InfoFormat("\t try to LOADING = {0}", strLoading);
            //    if ("正在获取校验码".Equals(strLoading))
            //    {
            //        if (retry > 3)//4次都在获取
            //            return;//放弃本次出价
            //        logger.InfoFormat("\t re-try {0}", ++retry);
            //        System.Threading.Thread.Sleep(250);
            //    }
            //    else
            //        isLoading = false;
            //}

            logger.Info("\tBEGIN postCaptcha");
            String txtCaptcha = new HttpUtil().postByteAsFile(URL + "/receive/dynamic/captcha.do", content);
            logger.Info("\tEND   postCaptcha");

            logger.Info("\tBEGIN input ACTIVE CAPTCHA [" + type + "]");
            if (type == 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                    System.Threading.Thread.Sleep(50);
                }
            }
            else if (type == 1)
            {
                for (int i = 1; i < 5; i++)
                {
                    ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                    System.Threading.Thread.Sleep(50);
                }
            }
            else if (type == 2)
            {
                for (int i = 2; i < 6; i++)
                {
                    ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                    System.Threading.Thread.Sleep(50);
                }
            }
            logger.Info("\tEND   input ACTIVE CAPTCHA");

            {
                System.Threading.Thread.Sleep(50);
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult dr = MessageBox.Show("确定要提交出价吗?", "提交出价", messButton, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                if (dr == DialogResult.OK)
                {
                    logger.InfoFormat("用户选择确定出价");
                    ScreenUtil.SetCursorPos(points.buttons[0].x, points.buttons[0].y);//确定按钮
                    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

                    System.Threading.Thread.Sleep(1000);
                    ScreenUtil.SetCursorPos(points.buttons[0].x + 188 / 2, points.buttons[0].y - 10);//确定按钮
                    //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                }
                else
                {
                    logger.InfoFormat("用户选择取消出价");
                    ScreenUtil.SetCursorPos(points.buttons[0].x + 188, points.buttons[0].y);//取消按钮
                    ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                }

                //if (points.Length > 3)
                //{
                //    System.Threading.Thread.Sleep(50);
                //    ScreenUtil.SetCursorPos(points[3].X, points[3].Y);
                    //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                //}
            }
            logger.Info("END   验证码");
        }
コード例 #9
0
ファイル: SchedulerJob.cs プロジェクト: CapricornZ/autobid
        public void Execute()
        {
            ScreenUtil screen = new ScreenUtil();
            for (int i = 0; i < 5; i++)
            {
                screen.drawSomething(
                    SystemInformation.WorkingArea.Size.Width - 100,
                    SystemInformation.WorkingArea.Size.Height - 100,
                    this.message);

                Thread.Sleep(500);
            }
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: CapricornZ/autobid
 /// <summary>
 /// 测试价格
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button4_price_Click(object sender, EventArgs e)
 {
     System.Console.WriteLine(String.Format("{0} -- start TEST PRICE --", DateTime.Now.ToString("HH:mm:ss.ffff")));
     String[] pos = this.textBox2.Text.Split(new char[] { ',' });
     byte[] content = new ScreenUtil().screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 100, 24);
     this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));
     String txtPrice = this.m_orcPrice.getCharFromPic(new Bitmap(this.pictureBox3.Image));
     PictureBox[] controlls = new PictureBox[]{
         this.pictureBox4, this.pictureBox5, this.pictureBox6,
         this.pictureBox7, this.pictureBox8, this.pictureBox9
     };
     for (int i = 0; i < this.m_orcPrice.SubImgs.Count; i++)
         controlls[i].Image = this.m_orcPrice.SubImgs[i];
     this.label1.Text = txtPrice;
     System.Console.WriteLine(String.Format("{0} -- end TEST PRICE --", DateTime.Now.ToString("HH:mm:ss.ffff")));
 }
コード例 #11
0
ファイル: Form1.cs プロジェクト: CapricornZ/autobid
        /// <summary>
        /// 测试验证码提示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button5_tips_Click(object sender, EventArgs e)
        {
            //m_orcCaptchaUtil
            System.Console.WriteLine(String.Format("{0} -- start TEST TIPs --", DateTime.Now.ToString("HH:mm:ss.ffff")));
            String[] pos = this.textBox2.Text.Split(new char[] { ',' });
            byte[] content = new ScreenUtil().screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 140, 24);
            this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));
            #region DEBUG
            File.WriteAllBytes("tips.bmp", content);
            #endregion
            //String txtTips = this.m_orcCaptchaTip.getCharFromPic(new Bitmap(this.pictureBox3.Image));
            this.label2.Text = this.m_orcCaptchaTipsUtil.getActive("123456", new Bitmap(new MemoryStream(content)));
            PictureBox[] controlls = new PictureBox[]{
                this.pictureBox4, this.pictureBox5, this.pictureBox6,
                this.pictureBox7, this.pictureBox8, this.pictureBox9
            };
            for (int i = 0; i < this.m_orcCaptchaTipsUtil.SubImgs.Count; i++)
                controlls[i].Image = this.m_orcCaptchaTipsUtil.SubImgs[i];

            System.Console.WriteLine(String.Format("{0} -- end TEST TIPs --", DateTime.Now.ToString("HH:mm:ss.ffff")));
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: CapricornZ/autobid
        /// <summary>
        /// 测试验证码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_captcha_Click(object sender, EventArgs e)
        {
            ScreenUtil screen = new ScreenUtil();
            String[] pos = this.textBox2.Text.Split(new char[] { ',' });
            byte[] content = screen.screenCaptureAsByte(Int32.Parse(pos[0]), Int32.Parse(pos[1]), 120, 38);
            this.pictureBox3.Image = Bitmap.FromStream(new System.IO.MemoryStream(content));

            #region DEBUG
            File.WriteAllBytes("captcha.bmp", content);
            //Bitmap subImg = screen.subImage(new Bitmap(new MemoryStream(content)));
            //this.pictureBox3.Image = subImg;
            //MemoryStream ms = new MemoryStream();
            //subImg.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            //content = ms.ToArray();
            //ms.Close();
            #endregion

            if (this.checkBox1.Checked)//如果选中“校验码”
            {
                String txtCaptcha = new HttpUtil().postByteAsFile(this.textURL.Text + "/receive/dynamic/captcha/detail.do", content);
                String[] array = Newtonsoft.Json.JsonConvert.DeserializeObject<String[]>(txtCaptcha);

                this.pictureBox4.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[0])));
                this.pictureBox5.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[1])));
                this.pictureBox6.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[2])));
                this.pictureBox7.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[3])));
                this.pictureBox8.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[4])));
                this.pictureBox9.Image = new Bitmap(new MemoryStream(Convert.FromBase64String(array[5])));
                this.label1.Text = array[6];
                //String txtCaptcha = new HttpUtil().postByteAsFile(this.textURL.Text + "/receive/captcha/red.do", content);
                //this.label1.Text = txtCaptcha;

            }
            else//测试“正在加载校验码”
            {
                String strLoading = this.m_orcCaptchaLoading.getCharFromPic(new Bitmap(new System.IO.MemoryStream(content)));

                this.pictureBox4.Image = this.m_orcCaptchaLoading.SubImgs[0];
                this.pictureBox5.Image = this.m_orcCaptchaLoading.SubImgs[1];
                this.pictureBox6.Image = this.m_orcCaptchaLoading.SubImgs[2];
                this.pictureBox7.Image = this.m_orcCaptchaLoading.SubImgs[3];
                this.pictureBox7.Image = this.m_orcCaptchaLoading.SubImgs[4];
                this.pictureBox7.Image = this.m_orcCaptchaLoading.SubImgs[5];
                this.label2.Text = strLoading;
            }
        }
コード例 #13
0
        private Boolean submit(String URL, SubmitPrice submitPoints)
        {
            logger.Info("BEGIN giveCAPTCHA");
            logger.Info("\tBEGIN make INPUT blank");
            logger.DebugFormat("INPUT BOX({0}, {1})", submitPoints.inputBox.x, submitPoints.inputBox.y);
            ScreenUtil.SetCursorPos(submitPoints.inputBox.x, submitPoints.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            logger.Info("\tEND   make INPUT blank");

            logger.Info("\tBEGIN identify CAPTCHA...");
            byte[] binaryCaptcha = null;
            Boolean isLoading = true;
            int retry = 0;
            Thread.Sleep(1000);//等待1秒钟(等待验证码或者“正在获取验证码”字样出来
            logger.DebugFormat("CAPTURE CAPTCHA({0}, {1})", submitPoints.captcha[0].x, submitPoints.captcha[0].y);
            while (isLoading)//重试3.5秒钟
            {
                binaryCaptcha = new ScreenUtil().screenCaptureAsByte(submitPoints.captcha[0].x, submitPoints.captcha[0].y, 128, 28);
                File.WriteAllBytes(String.Format("AUTO-LOADING-{0}.BMP", retry), binaryCaptcha);
                String strLoading = this.m_orcLoading.IdentifyStringFromPic(new Bitmap(new MemoryStream(binaryCaptcha)));
                logger.InfoFormat("\t LOADING({0}) = {1}", retry++, strLoading);
                if ("正在获取校验码".Equals(strLoading))
                {
                    if (retry > 14)
                    {
                        //重试1,2,3,4     ->1秒
                        //重试5,6,7,8     ->2秒
                        //重试9,10,11,12  ->3秒
                        //重试13,14       ->0.5秒
                        //都在获取校验码
                        logger.InfoFormat("Loading captcha timeout. 放弃 close & re-open");
                        ScreenUtil.SetCursorPos(submitPoints.buttons[0].x + 188, submitPoints.buttons[0].y);//取消按钮
                        ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                        return false;//放弃本次出价
                    }
                    Thread.Sleep(250);
                }
                else
                    isLoading = false;
            }

            File.WriteAllBytes("AUTO-CAPTCHA.BMP", binaryCaptcha);
            String txtCaptcha = this.m_orcCaptcha.IdentifyStringFromPic(new Bitmap(new System.IO.MemoryStream(binaryCaptcha)));
            logger.DebugFormat("CAPTURE TIPS({0}, {1})", submitPoints.captcha[1].x, submitPoints.captcha[1].y);
            byte[] binaryTips = new ScreenUtil().screenCaptureAsByte(submitPoints.captcha[1].x, submitPoints.captcha[1].y, 112, 16);
            File.WriteAllBytes("AUTO-TIPS.BMP", binaryCaptcha);
            String strActive = this.m_captchaUtil.getActive(txtCaptcha, new Bitmap(new System.IO.MemoryStream(binaryTips)));
            logger.InfoFormat("\tEND   identify CAPTCHA = {0}, ACTIVE = {1}", txtCaptcha, strActive);

            logger.Info("\tBEGIN input CAPTCHA");
            {
                for (int i = 0; i < strActive.Length; i++)
                {
                    ScreenUtil.keybd_event(ScreenUtil.keycode[strActive[i].ToString()], 0, 0, 0);
                    ScreenUtil.keybd_event(ScreenUtil.keycode[strActive[i].ToString()], 0, 0x2, 0);
                    System.Threading.Thread.Sleep(50);
                }
            }
            logger.Info("\tEND   input CAPTCHA");

            logger.Info("\tBEGIN click BUTTON[确定]");
            logger.DebugFormat("BUTTON[确定]({0}, {1})", submitPoints.buttons[0].x, submitPoints.buttons[0].y);
            ScreenUtil.SetCursorPos(submitPoints.buttons[0].x, submitPoints.buttons[0].y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            logger.Info("\tEND   click BUTTON[确定]");

            ScreenUtil.SetCursorPos(submitPoints.buttons[0].x + 188 / 2, submitPoints.buttons[0].y - 10);//确定按钮
            logger.Info("END   giveCAPTCHA");
            return true;
        }
コード例 #14
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        /// <summary>
        /// 出校验码,【for CTRL+左、上、右】
        /// </summary>
        /// <param name="URL"></param>
        /// <param name="bid"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        private Boolean submit(String URL, tobid.rest.position.BidStep2 bid, CaptchaInput input)
        {
            logger.WarnFormat("BEGIN submitCAPTCHA({0})", input);
            logger.Info("\tBEGIN make INPUT blank");
            logger.DebugFormat("\tINPUT BOX({0}, {1})", bid.submit.inputBox.x, bid.submit.inputBox.y);
            ScreenUtil.SetCursorPos(bid.submit.inputBox.x, bid.submit.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            logger.Info("\tEND   make INPUT blank");

            logger.Info("\tBEGIN identify CAPTCHA...");
            logger.DebugFormat("\tCAPTURE CAPTCHA({0}, {1})", bid.submit.captcha[0].x, bid.submit.captcha[0].y);
            byte[] binaryCaptcha = new ScreenUtil().screenCaptureAsByte(bid.submit.captcha[0].x, bid.submit.captcha[0].y, 128, 28);
            File.WriteAllBytes("CAPTCHA.BMP", binaryCaptcha);
            String txtCaptcha = this.m_orcCaptcha.IdentifyStringFromPic(new Bitmap(new MemoryStream(binaryCaptcha)));

            logger.DebugFormat("\tCAPTURE TIPS({0}, {1})", bid.submit.captcha[1].x, bid.submit.captcha[1].y);
            byte[] binaryTips = new ScreenUtil().screenCaptureAsByte(bid.submit.captcha[1].x, bid.submit.captcha[1].y, 112, 16);
            File.WriteAllBytes("TIPS.BMP", binaryTips);
            String txtActive = this.m_orcCaptchaTipsUtil.getActive(txtCaptcha, new Bitmap(new MemoryStream(binaryTips)));
            logger.InfoFormat("\tEND   identify CAPTCHA = {0}, ACTIVE = {1}", txtCaptcha, txtActive);

            logger.Info("\tBEGIN input CAPTCHA");
            {
                if (CaptchaInput.LEFT == input) {

                    for (int i = 0; i <= 3; i++) {
                        System.Threading.Thread.Sleep(25);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0x2, 0);
                    }
                }
                if (CaptchaInput.MIDDLE == input) {

                    for (int i = 1; i <= 4; i++) {

                        System.Threading.Thread.Sleep(25);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0x2, 0);
                    }
                }
                if (CaptchaInput.RIGHT == input) {

                    for (int i = 2; i <= 5; i++) {

                        System.Threading.Thread.Sleep(25);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0, 0);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtCaptcha[i].ToString()], 0, 0x2, 0);
                    }
                }
                if (CaptchaInput.AUTO == input) {

                    for (int i = 0; i < txtActive.Length; i++) {

                        System.Threading.Thread.Sleep(25);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtActive[i].ToString()], 0, 0, 0);
                        ScreenUtil.keybd_event(ScreenUtil.keycode[txtActive[i].ToString()], 0, 0x2, 0);
                    }
                }
            }
            logger.Info("\tEND   input CAPTCHA");

            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            DialogResult dr = MessageBox.Show("确定要提交出价吗?", "提交出价", messButton, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
            if (dr == DialogResult.OK) {
                logger.InfoFormat("用户选择确定出价");
                logger.DebugFormat("\tBUTTON[确定]({0}, {1})", bid.submit.buttons[0].x, bid.submit.buttons[0].y);
                ScreenUtil.SetCursorPos(bid.submit.buttons[0].x, bid.submit.buttons[0].y);//确定按钮
                ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

                //System.Threading.Thread.Sleep(1000);
                //ScreenUtil.SetCursorPos(bid.submit.buttons[0].x + 188 / 2, bid.submit.buttons[0].y - 10);//确定按钮
                //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                //ScreenUtil.SetCursorPos(bid.submit.buttons[0].x + 188 / 2, bid.submit.buttons[0].y - 10);//确定按钮
                logger.Info("END   submitCAPTCHA");
                return true;
            } else {
                logger.InfoFormat("用户选择取消出价");
                logger.DebugFormat("\tBUTTON[取消]({0}, {1})", bid.submit.buttons[0].x+188, bid.submit.buttons[0].y);
                ScreenUtil.SetCursorPos(bid.submit.buttons[0].x + 188, bid.submit.buttons[0].y);//取消按钮
                ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
                logger.Info("END   submitCAPTCHA");
                return false;
            }

            //logger.Info("\tBEGIN click BUTTON[确定]");
            //ScreenUtil.SetCursorPos(bid.submit.buttons[0].x, bid.submit.buttons[0].y);
            //ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            //logger.Info("\tEND   click BUTTON[确定]");
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        private void processEnter()
        {
            //int x=937, y=276;
            //byte[] title = new ScreenUtil().screenCaptureAsByte(x+35-2, y+84+1, 150, 40);
            int x = 937, y = 276;
            //1170,585
            byte[] title = new ScreenUtil().screenCaptureAsByte(x + 30, y + 80, 170, 50);
            Bitmap bitTitle = new Bitmap(new MemoryStream(title));
            String strTitle = this.m_orcTitle.IdentifyStringFromPic(bitTitle);
            if ("系统提示".Equals(strTitle)) {

                logger.Info("proces Enter in [系统提示]");
                ScreenUtil.SetCursorPos(1170, 585);
                ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            } else if ("投标拍卖".Equals(strTitle)) {

                logger.Info("proces Enter in [投标拍卖]");
                this.submitCaptcha(SubmitPriceStep2Job.getPosition());
            }
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: CapricornZ/bidHelper
        /// <summary>
        /// 绝对价格,出价
        /// </summary>
        /// <param name="givePrice">坐标</param>
        /// <param name="price">绝对价</param>
        private void givePrice(tobid.rest.position.BidStep2 bid, String txtPrice)
        {
            logger.WarnFormat("BEGIN givePRICE({0})", txtPrice);

            //INPUT BOX
            logger.InfoFormat("\tBEGIN input PRICE : {0}", txtPrice);
            ScreenUtil.SetCursorPos(bid.give.inputBox.x, bid.give.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["BACKSPACE"], 0, 0x2, 0);

            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);
            //System.Threading.Thread.Sleep(25); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0, 0); ScreenUtil.keybd_event(ScreenUtil.keycode["DELETE"], 0, 0x2, 0);

            for (int i = 0; i < txtPrice.Length; i++) {
                System.Threading.Thread.Sleep(25);
                ScreenUtil.keybd_event(ScreenUtil.keycode[txtPrice[i].ToString()], 0, 0, 0);
                ScreenUtil.keybd_event(ScreenUtil.keycode[txtPrice[i].ToString()], 0, 0x2, 0);
            }
            logger.Info("\tEND   input PRICE");

            //点击出价
            logger.Info("\tBEGIN click BUTTON[出价]");
            System.Threading.Thread.Sleep(50);
            ScreenUtil.SetCursorPos(bid.give.button.x, bid.give.button.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);
            logger.Info("\tEND   click BUTTON[出价]");
            logger.Info("END   givePRICE");

            ScreenUtil.SetCursorPos(bid.submit.inputBox.x, bid.submit.inputBox.y);
            ScreenUtil.mouse_event((int)(MouseEventFlags.Absolute | MouseEventFlags.LeftDown | MouseEventFlags.LeftUp), 0, 0, 0, IntPtr.Zero);

            //启动线程截校验码
            System.Threading.Thread loading = new System.Threading.Thread(delegate() {
                ScreenUtil screen = new ScreenUtil();
                for (int i = 0; i < 50; i++)//5秒钟
                {
                    logger.Debug("LOADING captcha...");
                    byte[] binaryCaptcha = new ScreenUtil().screenCaptureAsByte(bid.submit.captcha[0].x, bid.submit.captcha[0].y, 128, 28);
                    this.pictureCaptcha.Image = Bitmap.FromStream(new MemoryStream(binaryCaptcha));
                    System.Threading.Thread.Sleep(100);
                }
            });
            loading.Start();
            this.textInputCaptcha.Focus();
        }