示例#1
0
 public void MouseToPoint_UpdateExpectedPos(Point p, int screenId, int clickId, I5_MouseAndKeyboard iMouse)
 {
     if (_lastStoredImage != null)
     {
         MyPic picNew = (MyPic)_lastStoredImage.thePic.myPic.getClone();
         Size  s      = picNew.getDimenion();
         int   dim    = 15;
         for (int ix = -dim; ix < dim; ix += 3)
         {
             for (int iy = -dim; iy < dim; iy += 3)
             {
                 int X = p.X + ix;
                 int Y = p.Y + iy;
                 if ((X > 0) && (X < s.Width) && (Y > 0) && (Y < s.Height))
                 {
                     int       ixy = ix + iy;
                     PixelInfo picInf;
                     if ((ixy % 2) == 0)
                     {
                         picInf = PixelInfo.White;
                     }
                     else
                     {
                         picInf = PixelInfo.Black;
                     }
                     picNew.setPixel(X, Y, picInf);
                 }
             }
         }
         ImageStore_ScreenStore(new MyPicWithOriginalStream(picNew), new IdAndStep(screenId, id, true, clickId));
     }
     ExpectedMousePos = p;
     iMouse.MouseToPoint(p);
 }
示例#2
0
        private void cl(MyPic pic, EventArgs e)
        {
            this.panel1.Controls.Remove(pic);
            score = score + 100;

            toolStripLabel1.Text = "score: " + score.ToString();
        }
示例#3
0
        /*参数;图片列表
         * 参数:面板
         * 参数传递:showlist    用于保存已选择的图片
         * 参数:pictureBox   用于保存生成picturebox的列表
         * 参数:panel    传递主面板 过来   用于把控件添加到主面板中
         * 参数:pictureRightBoxlist    用于保存  右边生成的picturebox的面板
         * 参数:erroButtonRightBoxlist  用于保存   错误率的按钮列表
         * 参数:erro_count  错误率列表
         * 参数:solutionButtonRightBoxlist  解析按钮     把解析的按钮保存到这个列表 中
         * 参数:answerList    答案的地址    用于传递到解析按钮中   处理事件
         * 添加控件
         * */
        public static void createControl(List <Image> imgList, Panel panel1, List <Image> showImglist, List <MyPic> pictureBoxList, Panel panel, List <MyPic> pictureRightBoxlist, List <MyButton> erroButtonRightBoxlist, List <double> erro_count, List <MyButton> solutionButtonRightBoxlist, List <String> answerList)
        {
            int imgheight = 0;

            for (int i = 0; i < imgList.Count; i++)
            {
                Bitmap aa = new Bitmap(imgList[i]);
                Image  a  = PictureMerge.GetThumbnail(aa, 1240, 0);
                Bitmap ac = new Bitmap(a);
                Image  b  = PictureMerge.GetThumbnail(ac, 578, 0);
                Panel  p  = createPanel(0, imgheight, 578, b.Height + 25);

                MyPic pb = createPictureBox(0, 0, 578, b.Height, b);
                pb.indexCount = i;

                pb.MouseClick += (e, f) => pictureBox_MouseClick(pb, imgList[pb.indexCount], showImglist, pb.indexCount, panel, pictureRightBoxlist, imgList, pictureBoxList);
                pictureBoxList.Add(pb);

                p.CreateGraphics().DrawLine(Pens.Red, 0, b.Height, 578, b.Height);

                //graph.DrawLine(new Pen(Color.Red, 2), new System.Drawing.Font("宋体", 50, FontStyle.Bold), Brushes.DimGray, 0, iHeight);
                MyButton solution_Button = createButton("解析", 0, pb.Height + 1, 80, 23);
                if (i < answerList.Count)
                {
                    solution_Button.solutionPath = answerList[i];
                }
                solution_Button.MouseClick += (e, f) => solution_MouseClick("解析", solution_Button.solutionPath);//添加事件
                solutionButtonRightBoxlist.Add(solution_Button);
                Button join_Button = createButton("加入组卷车", 120, pb.Height + 1, 80, 23);
                join_Button.MouseClick += (e, f) => join_MouseClick("加入组卷车");

                Button remind_Button = createButton("特别提醒", 240, pb.Height + 1, 80, 23);
                remind_Button.MouseClick += (e, f) => remind_MouseClick("特别提醒");

                Button count_Button = createButton("组卷次数", 360, pb.Height + 1, 80, 23);
                count_Button.MouseClick += (e, f) => count_MouseClick("组卷次数");

                MyButton error_Button = createButton("错误率" + erro_count[i], 478, pb.Height + 1, 80, 23);
                if (i < erro_count.Count)
                {
                    error_Button.error_Count = erro_count[i];
                }
                error_Button.MouseClick += (e, f) => error_MouseClick("错误率", error_Button.error_Count);
                erroButtonRightBoxlist.Add(error_Button);

                //p.Size = new Size(578, b.Height + 23);
                p.Controls.Add(solution_Button);
                p.Controls.Add(join_Button);
                p.Controls.Add(remind_Button);
                p.Controls.Add(count_Button);
                p.Controls.Add(error_Button);
                p.Controls.Add(pb);
                if (p != null)
                {
                    panel1.Controls.Add(p);
                }
                imgheight += b.Height + 50;
            }
        }
示例#4
0
 public MyPicWithOriginalStream(Image orig)
 {
     origStream = new MemoryStream();
     orig.Save(origStream, System.Drawing.Imaging.ImageFormat.Bmp);
     origStream.Seek(0, SeekOrigin.Begin);
     myPic = new MyPic((Bitmap)orig);
     orig.Dispose();
 }
示例#5
0
        //产生PictureBox控件
        public static MyPic createPictureBox(int localX, int localY, int width, int height, Image img)
        {
            MyPic p = new MyPic();

            p.Location = new Point(localX, localY);

            p.Size        = new Size(width, height);
            p.Image       = img;
            p.BorderStyle = BorderStyle.FixedSingle;
            p.Enabled     = true;
            //p.CreateGraphics().DrawLine(Pens.Red, p.Width / 2, 0, p.Width / 2, p.Height);
            return(p);
        }
示例#6
0
        /*参数:图片 设置picturebox的图片
         * 参数:面板 传递面板2 修改里面的控件
         * 参数;控件列表   管理PictureBox控件
         * 参数:i   传递标记
         * 参数:imgheight    用来设置picturebox控件的位置
         * 参数:showImglist   管理显示的图片
         * 参数:imgList   管理显示的图片在imgList的索引
         * 添加控件
         * */
        public static void createRightControl(Image img, Panel panel1, List <MyPic> pictureRightBoxlist, int i, int imgheight, List <Image> showImglist, List <Image> imgList, List <MyPic> pictureBoxList)
        {
            Bitmap ac = new Bitmap(img);
            Image  b  = PictureMerge.GetThumbnail(ac, 578, 0);
            MyPic  pb = createPictureBox(0, imgheight, 578, b.Height, b);

            pb.indexCount = i;
            pictureRightBoxlist.Add(pb);
            panel1.VerticalScroll.Value = 0;
            panel1.Controls.Add(pb);
            panel1.Refresh();
            pb.MouseClick += (e, f) => pictureBoxRight_MouseClick(pb.indexCount, showImglist, imgList, pictureRightBoxlist, panel1, pictureBoxList);
            //MessageBox.Show(pb.Location.ToString());
        }
示例#7
0
        private void tf()
        {
            while (true)
            {
                Thread.Sleep(100);

                foreach (Control pic in this.panel1.Controls)
                {
                    if (pic.Name.Contains("mypic"))
                    {
                        MyPic c = (MyPic)pic;

                        if ((this.InvokeRequired) && (c.mylife > 160))
                        {
                            this.panel1.Controls.Remove(pic);
                        }
                    }
                }

                //控制大小
                foreach (Control pic in this.panel1.Controls)
                {
                    if (pic.Name.Contains("mypic"))
                    {
                        MyPic c = (MyPic)pic;
                        c.mylife++;

                        if (c.Width > 80)
                        {
                            c.tobig = false;
                        }
                        if (c.Width < 10)
                        {
                            c.tobig = true;
                        }

                        if (c.tobig)
                        {
                            c.Size = new Size(c.Width + 1, c.Height + 1);
                        }
                        else
                        {
                            c.Size = new Size(c.Width - 1, c.Height - 1);
                        }
                    }
                }
            }
        }
示例#8
0
        private void initone()
        {
            MyPic pic = new MyPic();

            pic.Name      = "mypic";
            pic.Image     = Properties.Resources.yyyy;
            pic.BackColor = Color.Transparent;

            Random ran   = new Random(GetRandomSeed());
            int    Randx = ran.Next(10, 900);
            int    y     = ran.Next(10, 500);

            pic.Top  = y;
            pic.Left = Randx;

            pic.Width  = 50;
            pic.Height = 50;

            pic.SizeMode = PictureBoxSizeMode.Zoom;

            pic.Click += delegate(Object o, EventArgs e1) { cl(pic, e1); };

            this.panel1.Controls.Add(pic);
        }
示例#9
0
 private void ScreenStoreSub(MyPic myPic, int screenId, _6WhatsAppProcess_RealData data)
 {
     data.ImageStore_ScreenStore(new MyPicWithOriginalStream(myPic), new IdAndStep(screenId, data.id, true, -1));
 }
示例#10
0
        private eI6Error processPreLogDone(string destMobile, string msg, Ix iAll)
        {
            if (iAll.TypeOfProcess == Ix.eTypeOfProcess.EmptyWakeUpTrigger)
            {
                // nothing else to do
                return(eI6Error.Success);
            }

            DateTime dtStart             = DateTime.Now;
            eI6Error ret                 = eI6Error._notSet;
            _6WhatsAppProcess_RealData u = new _6WhatsAppProcess_RealData(destMobile, msg, s_WhatsAppProcessCounter++);

            u.MouseToPoint_UpdateExpectedPos(new Point(200, 200), -1, -1, iAll.iMouse);
            iAll.iDsp.FileLog_Info("Id: " + u.id.ToString() + " " + destMobile);
            iAll.iDsp.AddLine("Id: " + u.id.ToString());
            iAll.iDsp.AddLine2(new DetailedData_ProcessingId(u.id));
            iAll.iScreen.Debug_SetId(u.id, u.Msg_DestMobile);

            SpecificResult_SearchGlas _1GlasPos = null;
            Point _2TelLinePos;
            Point _4RightOfSmile;

            // Step 1
            if (ret == eI6Error._notSet)
            {
                iAll.iDsp.FileLog_Debug("Step1 findSearchWindow and enter tel");
                iAll.iDsp.AddLine("Step1 findSearchWindow and enter tel");
                ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 1, u, eI6Error.Step1Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce)
                {
                    ix.iDsp.FileLog_Debug("Performing Step1...");
                    // delegate
                    MyPic pic = ScreenGet(screenId, data);

                    // 1) we search in the top left corner
                    Size wholeScreenSize = pic.getDimenion();
                    Rectangle sa         = new Rectangle(0, 0, wholeScreenSize.Width / 2, wholeScreenSize.Height / 2);
                    MyPic sub            = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height);
                    ScreenStoreSub(sub, screenId, data);
//                    ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("1sub");

                    // 2) Call the Dll to search for the SearchGlas
                    _1GlasPos = TextRecognitionLibrary.SpecificDetection.DetectSearchGlas(sub);

                    // 3) Check the Dll´s result
                    if (!_1GlasPos.XPos.IsEmpty)
                    {
                        // the x is there, so text was already entered
                        ix.iDsp.FileLog_Debug("The x is there " + _1GlasPos.XPos.ToString());
                        ix.iDsp.AddLine("X detected, increasing timeout");
                        data.MouseToPoint_UpdateExpectedPos(_1GlasPos.XPos, screenId, 1, ix.iMouse);
                        ix.iMouse.MouseClickAndWait(100, 300, ix);
                        increaseTimeoutOnce = true;
                    }
                    else if (_1GlasPos.SearchGlasPos.IsEmpty)
                    {
                        // no Searchglas found
                        ix.iDsp.FileLog_Debug("SearchGlasPos.IsEmpty");
                    }
                    else if (_1GlasPos.SearchGlasInFactIsABack)
                    {
                        // the <- arror is there, so text was already entered,
                        ix.iDsp.FileLog_Debug("<- detected at "
                                              + _1GlasPos.SearchGlasPos.ToString()
                                              + " / "
                                              + _1GlasPos.XPos.ToString());
                        data.MouseToPoint_UpdateExpectedPos(_1GlasPos.SearchGlasPos, screenId, 1, ix.iMouse);
                        ix.iMouse.MouseClickAndWait(100, 300, ix);
                        increaseTimeoutOnce = true;
                    }
                    else
                    {
                        // the SearchGlas is there, so click it
                        ix.iDsp.FileLog_Debug("SearchGlas @ " + _1GlasPos.SearchGlasPos.ToString());
                        data.MouseToPoint_UpdateExpectedPos(_1GlasPos.SearchGlasPos, screenId, 2, ix.iMouse);
                        ix.iDsp.Delay(300);
                        Point pWhereText = _1GlasPos.SearchGlasPos;
                        pWhereText.Offset(100, 0);
                        ix.iDsp.FileLog_Debug("pWhereText.click(" + pWhereText.ToString() + ")");
                        data.MouseToPoint_UpdateExpectedPos(pWhereText, screenId, 3, ix.iMouse);
                        ix.iMouse.MouseClickAndWait(100, 100, ix);

                        // Now enter the tel no
                        return(EnterTextAndCheckForMouseMove(data.Msg_DestMobile.Replace("+", ""), false, ix, data));
                    }
                    ix.iDsp.FileLog_Debug("Early out: Reason above.");
                    ix.iDsp.Delay(200);
                    return(eI6Error._notSet);
                });
            }
            if (ret == eI6Error._notSetBufOkSoFar)
            {
                ret = eI6Error._notSet;
            }

            // Step 2
            if (ret == eI6Error._notSet)
            {
                iAll.iDsp.FileLog_Debug("Step2 findAccount and Click it");
                iAll.iDsp.AddLine("Step2 findAccount and Click it");
                ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 2, u, eI6Error.Step2Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce)
                {
                    ix.iDsp.FileLog_Debug("Performing Step2...");
                    // delegate
                    MyPic pic = ScreenGet(screenId, data);

                    // 1) we search in a limitted area
                    Rectangle sa = new Rectangle(_1GlasPos.SearchGlasPos.X + 40, _1GlasPos.SearchGlasPos.Y + 10, 200, 250);
                    MyPic sub    = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height);
                    ScreenStoreSub(sub, screenId, data);
//                    ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("4AlmostBlack");

                    // 2) Call the Dll to search for the text
                    SpecificResult_Text rText = SpecificDetection.DetectText(sub);
                    if (rText.TextPos.IsEmpty)
                    {
                        ix.iDsp.FileLog_Debug("Early out: TextPos.IsEmpty");
                        ix.iDsp.Delay(200);
                        return(eI6Error._notSet);
                    }
                    ix.iDsp.FileLog_Info("Step2 tel text found: " + rText.Text);
                    bool first12AreTheSame;
                    if (!AreFirst12CharSame(data.Msg_DestMobile, rText.Text, out first12AreTheSame))
                    {
                        ix.iDsp.FileLog_Debug("Early out: Text is wrong");
                        ix.iDsp.Delay(200);
                        return(eI6Error._notSet);
                    }
                    if (first12AreTheSame)
                    {
                        ix.iDsp.FileLog_Debug("Text is not the same but we accept.");
                        ix.iDsp.FileLog_Debug(data.Msg_DestMobile);
                        ix.iDsp.FileLog_Debug(rText.Text);
                    }
                    _2TelLinePos = rText.TextPos;
                    _2TelLinePos.Offset(sa.X, sa.Y);
                    _2TelLinePos.Offset(0, 7);

                    ix.iDsp.FileLog_Debug("Step2 TelLine detected at " + _2TelLinePos.ToString());

                    // 3) and click on top of the tel string
                    data.MouseToPoint_UpdateExpectedPos(_2TelLinePos, screenId, 4, ix.iMouse);
                    ix.iMouse.MouseClickAndWait(100, 100, ix);

                    return(eI6Error._notSetBufOkSoFar);
                });
            }
            if (ret == eI6Error._notSetBufOkSoFar)
            {
                ret = eI6Error._notSet;
            }

            // Step 3
            if (ret == eI6Error._notSet)
            {
                iAll.iDsp.FileLog_Debug("Step3 verify account string top rigth position");
                iAll.iDsp.AddLine("Step3 verify account string top rigth position");
                ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 3, u, eI6Error.Step3Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce)
                {
                    ix.iDsp.FileLog_Debug("Performing Step3...");

                    // delegate
                    MyPic pic = ScreenGet(screenId, data);

                    // 1) we search in a limitted area
                    //Rectangle sa = new Rectangle(400, 100, 280, 80);
                    Rectangle sa = new Rectangle(475, 100, 200, 80);
                    MyPic sub    = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height);
                    ScreenStoreSub(sub, screenId, data);

                    // 2) Call the Dll to search for the text
                    SpecificResult_Text rText = SpecificDetection.DetectText(sub);
                    if (rText.TextPos.IsEmpty)
                    {
                        ix.iDsp.FileLog_Debug("Early out: TextPos.IsEmpty");
                        ix.iDsp.Delay(200);
                        return(eI6Error._notSet);
                    }
                    ix.iDsp.FileLog_Info("Step3 tel text fount: " + rText.Text);
                    if (!rText.Text.Contains(data.Msg_DestMobile.Replace("zapi_", "").Replace("+", "")))
                    {
                        ix.iDsp.FileLog_Debug("Early out: Text is wrong");
                        ix.iDsp.Delay(200);
                        return(eI6Error._notSet);
                    }
                    return(eI6Error._notSetBufOkSoFar);
                });
            }
            if (ret == eI6Error._notSetBufOkSoFar)
            {
                ret = eI6Error._notSet;
            }

            // Step 4
            if ((ret == eI6Error._notSet) && (iAll.TypeOfProcess == Ix.eTypeOfProcess.TelNumberChecking))
            {
                // we are done for tel checking
                ret = eI6Error.Success;
            }
            if (ret == eI6Error._notSet)
            {
                iAll.iDsp.FileLog_Debug("Step4 Find type-msg-here");
                iAll.iDsp.AddLine("Step4 Find type-msg-here");
                ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 4, u, eI6Error.Step4Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce)
                {
                    ix.iDsp.FileLog_Debug("Performing Step4...");

                    // delegate
                    MyPic pic = ScreenGet(screenId, data);

                    // 1) we serach in a specific area
                    Size wholeScreenSize = pic.getDimenion();
                    // was {X = 0 Y = 568 Width = 1024 Height = 200}
                    Rectangle sa = new Rectangle(
                        300,
                        wholeScreenSize.Height - 100,
                        wholeScreenSize.Width - 300,
                        100);
                    MyPic sub = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height);
                    ScreenStoreSub(sub, screenId, data);
//                    ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("8subAlmostBlac");

                    // 2) Call the Dll to search the simle and mic
                    specificResult_SmileAndMic s = TextRecognitionLibrary.SpecificDetection.SpecificResult_SmileAndMic(sub);
                    if (s.SmilePos.IsEmpty)
                    {
                        // no smile found
                        ix.iDsp.FileLog_Debug("Early out: No smile");
                        return(eI6Error._notSet);
                    }
                    else if (s.MicPos.IsEmpty)
                    {
                        // we have a smile not no mic ==> rubbishtext is there. So delete it
                        _4RightOfSmile = s.SmilePos;
                        _4RightOfSmile.Offset(sa.X, sa.Y);
                        _4RightOfSmile.Offset(300, 5);

                        data.MouseToPoint_UpdateExpectedPos(_4RightOfSmile, screenId, 5, ix.iMouse);
                        ix.iMouse.MouseClickAndWait(50, 50, ix);
                        EnterTextAndCheckForMouseMove("\b\b\b\b\b\b\b\b\b", false, ix, data);
                        ix.iDsp.FileLog_Debug("Early out: Rubbish text in chat box");
                        return(eI6Error._notSet);
                    }
                    // we have both, smile and mic
                    _4RightOfSmile = s.SmilePos;
                    _4RightOfSmile.Offset((s.MicPos.X - s.SmilePos.X) / 2, 0);
                    _4RightOfSmile.Offset(sa.X, sa.Y);

                    // 3) Set the mouse to the text box
                    data.MouseToPoint_UpdateExpectedPos(_4RightOfSmile, screenId, 6, ix.iMouse);

                    // 4) Click it
                    ix.iMouse.MouseClickAndWait(50, 50, ix);

                    // 5) And enter the text
                    if (data.Msg_Msg.StartsWith("__NoSend"))
                    {
                        ix.iDsp.AddLine("__NoSend");
                        ix.iDsp.FileLog_Info("__NoSend");
                    }
                    else
                    {
                        EnterTextAndCheckForMouseMove(data.Msg_Msg, true, ix, data);
                    }
                    return(eI6Error.Success);
                });
            }

            // END, clean up
            TimeSpan duration   = (DateTime.Now - dtStart);
            string   strDurtion = duration.ToReadableString();

            if (ret == eI6Error.Success)
            {
                // Success
                iAll.iDsp.Clear();
                iAll.iDsp.AddLine("Done in " + strDurtion);
                iAll.iDsp.AddLine2(new DetailedData_LastGoodProcess(u.id, duration));
                u.DumpImagesIfConfigured("NiceTray._6WhatsAppProcess_Real.DumpScreensOnSuccess", iAll);
            }
            else
            {
                // Problem
                iAll.iDsp.AddLine2(new DetailedData_LastBadProcess(u.id, duration));
                u.DumpImagesIfConfigured("NiceTray._6WhatsAppProcess_Real.DumpScreensOnProblem", iAll);
            }
            iAll.iDsp.FileLog_Info(
                "_6WhatsAppProcess_Real.Process took "
                + strDurtion
                + " "
                + (ret == eI6Error.Success ? "Success" : ret.ToString())
                );

            return(ret);
        }
示例#11
0
 public MyPicWithOriginalStream(MyPic pic)
 {
     myPic = (MyPic)pic.getClone();
 }