lk
2022-10-21 6a01d7eb50d4c351c0b050c628db7d7daf4e7a01
BankRobot/frmCollectTI.cs
@@ -98,7 +98,7 @@
        private void btnStart_Click(object sender, EventArgs e)
        {
            //启动
            Start();
            StartCommit();
            //try
            //{
            //    解析获取具体链接
@@ -191,137 +191,146 @@
        //}
        private void Start()
        private void StartCommit()
        {
            ////刷新
            //int refreshLeft = Convert.ToInt32(ConfigurationManager.AppSettings["refreshLeft"]);
            //int refreshTop = Convert.ToInt32(ConfigurationManager.AppSettings["refreshTop"]);
            //ClickButtonBy(refreshLeft, refreshTop);
            ////输入产品
            //int productLeft = Convert.ToInt32(ConfigurationManager.AppSettings["productLeft"]);
            //int productTop = Convert.ToInt32(ConfigurationManager.AppSettings["productTop"]);
            //if (txtURL.Text.Trim() != null)
            //{
            //    InputTextInfo(txtURL.Text.Trim(), productLeft, productTop);
            //}
            //else
            //{
            //    MessageBox.Show("请输入产品");
            //}
            //string strURL = HttpUtility.UrlEncode(txtURL.Text, Encoding.UTF8);
            //DelayTime(2000);
            ////点击搜索产品
            //int searchproductLeft = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductLeft"]);
            //int searchproductTop = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductTop"]);
            //ClickButtonBy(searchproductLeft, searchproductTop);
            //DelayTime(7000);
            ////指定位置输入购买数量
            //int purchasequantityLeft = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityLeft"]);
            //int purchasequantityTop = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityTop"]);
            //if (txtquantity.Text.Trim() != null)
            //{
            //    InputTextInfo(txtquantity.Text.Trim(), purchasequantityLeft, purchasequantityTop);
            //    DelayTime(2000);
            //}
            //else
            //{
            //    MessageBox.Show("请输入购买产品的数量");
            //}
            ////点击加入购物车
            //int shoppingcartLeft = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartLeft"]);
            //int shoppingcartTop = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartTop"]);
            //ClickButtonBy(shoppingcartLeft, shoppingcartTop);
            //DelayTime(7000);
            ////点击结算按钮
            //int settlementLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementLeft"]);
            //int settlementTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementTop"]);
            //ClickButtonBy(settlementLeft, settlementTop);
            //DelayTime(10000);
            ////点击购物车里结算按钮
            //int settlementtwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoLeft"]);
            //int settlementtwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoTop"]);
            //ClickButtonBy(settlementtwoLeft, settlementtwoTop);
            //DelayTime(10000);
            ////点击2次下滑,再点击(1)下一步
            int slidedownwardLeft = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardLeft"]);
            int slidedownwardTop = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardTop"]);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //DelayTime(2000);
            //int nextstepLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepLeft"]);
            //int nextstepTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepTop"]);
            //ClickButtonBy(nextstepLeft, nextstepTop);
            //DelayTime(15000);
            ////2.先点击必选框,再一次点击下滑,最后点击(2)下一步
            //int mandatoryLeft = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryLeft"]);
            //int mandatoryTop = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryTop"]);
            //ClickButtonBy(mandatoryLeft, mandatoryTop);
            //DelayTime(1000);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //int nextsteptwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoLeft"]);
            //int nextsteptwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoTop"]);
            //ClickButtonBy(nextsteptwoLeft, nextsteptwoTop);
            ////点击确认并继续
            //int determineLeft = Convert.ToInt32(ConfigurationManager.AppSettings["determineLeft"]);
            //int determineTop = Convert.ToInt32(ConfigurationManager.AppSettings["determineTop"]);
            //ClickButtonBy(determineLeft, determineTop);
            //DelayTime(20000);
            ////3.先点击下滑再点击(3)下一步
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //int nextstepthreeLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeLeft"]);
            //int nextstepthreeTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeTop"]);
            //ClickButtonBy(nextstepthreeLeft, nextstepthreeTop);
            //DelayTime(15000);
            //4.第4步没有
            //5.先点击下滑再点击服务条款阅读,再点击接受,点击下滑,最后点击(4)下一步
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //int serviceLeft = Convert.ToInt32(ConfigurationManager.AppSettings["serviceLeft"]);
            //int serviceTop = Convert.ToInt32(ConfigurationManager.AppSettings["serviceTop"]);
            //ClickButtonBy(serviceLeft, serviceTop);
            //int acceptLeft = Convert.ToInt32(ConfigurationManager.AppSettings["acceptLeft"]);
            //int acceptTop = Convert.ToInt32(ConfigurationManager.AppSettings["acceptTop"]);
            //ClickButtonBy(acceptLeft, acceptTop);
            //DelayTime(1000);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            //int nextstepfourLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourLeft"]);
            //int nextstepfourTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourTop"]);
            //ClickButtonBy(nextstepfourLeft, nextstepfourTop);
            //DelayTime(15000);
            ////6.先点击下滑,在选择支付宝或者微信支付,最后点击支付
            ////下滑
            //DelayTime(3000);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            ////选择支付宝付款
            //int alipayLeft = Convert.ToInt32(ConfigurationManager.AppSettings["alipayLeft"]);
            //int alipayTop = Convert.ToInt32(ConfigurationManager.AppSettings["alipayTop"]);
            //ClickButtonBy(alipayLeft, alipayTop);
            ////选择微信支付
            //int weChatLeft = Convert.ToInt32(ConfigurationManager.AppSettings["weChatLeft"]);
            //int weChatTop = Convert.ToInt32(ConfigurationManager.AppSettings["weChatTop"]);
            //ClickButtonBy(weChatLeft, weChatTop);
            //DelayTime(1000);
            //ClickButtonBy(slidedownwardLeft, slidedownwardTop);
            ////点击支付
            //int paymentLeft = Convert.ToInt32(ConfigurationManager.AppSettings["paymentLeft"]);
            //int paymentTop = Convert.ToInt32(ConfigurationManager.AppSettings["paymentTop"]);
            //ClickButtonBy(paymentLeft, paymentTop);
            //DelayTime(10000);
            int iLeft = Convert.ToInt32(ConfigurationManager.AppSettings["iLeft"]);
            int iTop = Convert.ToInt32(ConfigurationManager.AppSettings["iTop"]);
            string Base64Pic = ScreenVerifyCode(iLeft, iTop);
            string Result = GetNumbers.GeneralBasic(Base64Pic);
            JObject jo = new JObject();
            jo = JsonConvert.DeserializeObject<JObject>(Result);
            if (jo["words_result"] != null && jo["words_result"].ToString() != "")
            try
            {
                JObject words = jo["words_result"][0].Value<JObject>();
                richTextLog.Text += words["words"].ToString();
                MessageBox.Show("已成功完成订单,请支付");
                //刷新
                int refreshLeft = Convert.ToInt32(ConfigurationManager.AppSettings["refreshLeft"]);
                int refreshTop = Convert.ToInt32(ConfigurationManager.AppSettings["refreshTop"]);
                ClickButtonBy(refreshLeft, refreshTop);
                //输入产品
                int productLeft = Convert.ToInt32(ConfigurationManager.AppSettings["productLeft"]);
                int productTop = Convert.ToInt32(ConfigurationManager.AppSettings["productTop"]);
                if (txtURL.Text.Trim() != null)
                {
                    InputTextInfo(txtURL.Text.Trim(), productLeft, productTop);
                }
                else
                {
                    MessageBox.Show("请输入产品");
                }
                string strURL = HttpUtility.UrlEncode(txtURL.Text, Encoding.UTF8);
                DelayTime(3000);
                //点击搜索产品
                int searchproductLeft = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductLeft"]);
                int searchproductTop = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductTop"]);
                ClickButtonBy(searchproductLeft, searchproductTop);
                DelayTime(10000);
                //指定位置输入购买数量
                int purchasequantityLeft = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityLeft"]);
                int purchasequantityTop = Convert.ToInt32(ConfigurationManager.AppSettings["purchasequantityTop"]);
                if (txtquantity.Text.Trim() != null)
                {
                    InputTextInfo(txtquantity.Text.Trim(), purchasequantityLeft, purchasequantityTop);
                    DelayTime(2000);
                }
                else
                {
                    MessageBox.Show("请输入购买产品的数量");
                }
                //点击加入购物车
                int shoppingcartLeft = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartLeft"]);
                int shoppingcartTop = Convert.ToInt32(ConfigurationManager.AppSettings["shoppingcartTop"]);
                ClickButtonBy(shoppingcartLeft, shoppingcartTop);
                DelayTime(10000);
                //点击结算按钮
                int settlementLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementLeft"]);
                int settlementTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementTop"]);
                ClickButtonBy(settlementLeft, settlementTop);
                DelayTime(12000);
                //点击购物车里结算按钮
                int settlementtwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoLeft"]);
                int settlementtwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["settlementtwoTop"]);
                ClickButtonBy(settlementtwoLeft, settlementtwoTop);
                DelayTime(12000);
                //点击2次下滑,再点击(1)下一步
                int slidedownwardLeft = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardLeft"]);
                int slidedownwardTop = Convert.ToInt32(ConfigurationManager.AppSettings["slidedownwardTop"]);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                DelayTime(2000);
                int nextstepLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepLeft"]);
                int nextstepTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepTop"]);
                ClickButtonBy(nextstepLeft, nextstepTop);
                DelayTime(15000);
                //2.先点击必选框,再一次点击下滑,最后点击(2)下一步
                int mandatoryLeft = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryLeft"]);
                int mandatoryTop = Convert.ToInt32(ConfigurationManager.AppSettings["mandatoryTop"]);
                ClickButtonBy(mandatoryLeft, mandatoryTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextsteptwoLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoLeft"]);
                int nextsteptwoTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextsteptwoTop"]);
                ClickButtonBy(nextsteptwoLeft, nextsteptwoTop);
                //点击确认并继续
                int determineLeft = Convert.ToInt32(ConfigurationManager.AppSettings["determineLeft"]);
                int determineTop = Convert.ToInt32(ConfigurationManager.AppSettings["determineTop"]);
                ClickButtonBy(determineLeft, determineTop);
                DelayTime(20000);
                //3.先点击下滑再点击(3)下一步
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextstepthreeLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeLeft"]);
                int nextstepthreeTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepthreeTop"]);
                ClickButtonBy(nextstepthreeLeft, nextstepthreeTop);
                DelayTime(15000);
                //4.第4步没有
                //5.先点击下滑再点击服务条款阅读,再点击接受,点击下滑,最后点击(4)下一步
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int serviceLeft = Convert.ToInt32(ConfigurationManager.AppSettings["serviceLeft"]);
                int serviceTop = Convert.ToInt32(ConfigurationManager.AppSettings["serviceTop"]);
                ClickButtonBy(serviceLeft, serviceTop);
                int acceptLeft = Convert.ToInt32(ConfigurationManager.AppSettings["acceptLeft"]);
                int acceptTop = Convert.ToInt32(ConfigurationManager.AppSettings["acceptTop"]);
                ClickButtonBy(acceptLeft, acceptTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                int nextstepfourLeft = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourLeft"]);
                int nextstepfourTop = Convert.ToInt32(ConfigurationManager.AppSettings["nextstepfourTop"]);
                ClickButtonBy(nextstepfourLeft, nextstepfourTop);
                DelayTime(15000);
                //6.先点击下滑,再选择支付宝或者微信支付,最后点击支付
                //下滑
                DelayTime(3000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                //选择支付宝付款
                int alipayLeft = Convert.ToInt32(ConfigurationManager.AppSettings["alipayLeft"]);
                int alipayTop = Convert.ToInt32(ConfigurationManager.AppSettings["alipayTop"]);
                ClickButtonBy(alipayLeft, alipayTop);
                //选择微信支付
                //int weChatLeft = Convert.ToInt32(ConfigurationManager.AppSettings["weChatLeft"]);
                //int weChatTop = Convert.ToInt32(ConfigurationManager.AppSettings["weChatTop"]);
                //ClickButtonBy(weChatLeft, weChatTop);
                DelayTime(1000);
                ClickButtonBy(slidedownwardLeft, slidedownwardTop);
                //点击支付
                int paymentLeft = Convert.ToInt32(ConfigurationManager.AppSettings["paymentLeft"]);
                int paymentTop = Convert.ToInt32(ConfigurationManager.AppSettings["paymentTop"]);
                ClickButtonBy(paymentLeft, paymentTop);
                DelayTime(10000);
                int iLeft = Convert.ToInt32(ConfigurationManager.AppSettings["iLeft"]);
                int iTop = Convert.ToInt32(ConfigurationManager.AppSettings["iTop"]);
                string Base64Pic = ScreenVerifyCode(iLeft, iTop);
                string Result = GetNumbers.GeneralBasic(Base64Pic);
                JObject jo = new JObject();
                jo = JsonConvert.DeserializeObject<JObject>(Result);
                if (jo["words_result"] != null && jo["words_result"].ToString() != "")
                {
                    JObject words = jo["words_result"][0].Value<JObject>();
                    richTextLog.Text += words["words"].ToString();
                    MessageBox.Show("已成功完成订单,请支付");
                }
                else
                {
                    MessageBox.Show("订单出现错误!");
                }
            }
            else
            catch (Exception)
            {
                MessageBox.Show("订单出现错误!");
                throw;
            }
        }
@@ -342,7 +351,7 @@
            gla.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            gla.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            gla.CopyFromScreen(iLeft, iTop, 0, 0, new Size(iWidth, iHeight));
            myImage.Save(System.AppDomain.CurrentDomain.BaseDirectory + "/ZFJT.png");
            myImage.Save(System.AppDomain.CurrentDomain.BaseDirectory + "/ZFZM.png");
            //字面是对当前图片进行了二进制转换
            MemoryStream ms = new MemoryStream();
            myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
@@ -391,8 +400,25 @@
        private void btnStop_Click(object sender, EventArgs e)
        {
            //ResetSystem("系统自动抓取手动停止!");
            ResetSystem("系统自动抓取手动停止!");
        }
        /// <summary>
        /// 系统重新置位
        /// </summary>
        /// <param name="strInfo"></param>
        private void ResetSystem(string strInfo, bool bContinueFlag = false)
        {
            bStop = true;
            btnStart.Enabled = !bContinueFlag;
            btnContinue.Enabled = bContinueFlag;
            btnStop.Enabled = bContinueFlag;
            lblStatus.Text = strInfo;
            timer1.Enabled = false;
            iCount = 0;
            richTextLog.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ResetSystem系统重置!原因:" + strInfo + "\r\n";
        }
        /// <summary>
        /// 延迟函数防止假死
@@ -415,5 +441,46 @@
            }
            return;
        }
        private void repeat_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 1;
                while (1 < 3)
                {
                    //刷新
                    int refreshLeft = Convert.ToInt32(ConfigurationManager.AppSettings["refreshLeft"]);
                    int refreshTop = Convert.ToInt32(ConfigurationManager.AppSettings["refreshTop"]);
                    ClickButtonBy(refreshLeft, refreshTop);
                    //输入产品
                    int productLeft = Convert.ToInt32(ConfigurationManager.AppSettings["productLeft"]);
                    int productTop = Convert.ToInt32(ConfigurationManager.AppSettings["productTop"]);
                    if (txtproduct.Text.Trim() != null)
                    {
                        InputTextInfo(txtproduct.Text.Trim(), productLeft, productTop);
                    }
                    else
                    {
                        MessageBox.Show("请输入产品");
                    }
                    string strURL = HttpUtility.UrlEncode(txtproduct.Text, Encoding.UTF8);
                    DelayTime(2000);
                    //点击搜索产品
                    int searchproductLeft = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductLeft"]);
                    int searchproductTop = Convert.ToInt32(ConfigurationManager.AppSettings["searchproductTop"]);
                    ClickButtonBy(searchproductLeft, searchproductTop);
                    MessageBox.Show("因为没有库存所以会每10秒循坏1次,因为是演示,所以只循环三次,当前是第" + i + "次循环");
                    i++;
                    DelayTime(10000);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}