示例#1
0
        public List <Bitmap> collectMapMiniPath()
        {
            mAuto.writeStatus("Thu thập mảnh bản đồ");
            List <Bitmap> mapPaths = new List <Bitmap>();

            // Mở bảng đồ mini
            //mAuto.clickToImage(Constant.ImagePathMiniMap);
            mAuto.sendKey("~");

            var full_screen = CaptureHelper.CaptureWindow(mHWnd);

            // Tắt các bảng nổi
            mAuto.closeAllDialog();

            Bitmap iBtn = ImageScanOpenCV.GetImage(Constant.ImagePathGlobalMiniMap);
            var    pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)full_screen, iBtn);

            if (pBtn != null)
            {
                int x_start_point = pBtn.Value.X + 0;
                int y_start_point = pBtn.Value.Y + 60;
                for (int y = 0; y < 5; y++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        mapPaths.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(
                                                                 x_start_point + (x * 100),
                                                                 y_start_point + (y * 56),
                                                                 100, 56)));
                    }
                }
            }

            return(mapPaths);
        }
示例#2
0
        public static void saveImage(int x, int y, int width, int height)
        {
            var scene = CaptureHelper.CaptureWindow(Global.mainHandle);

            scene = CaptureHelper.CropImage(scene, new System.Drawing.Rectangle(x, y, width, height));
            scene.Save("./img/debug/saveImage.png");
        }
示例#3
0
        private void buttonClickRightOnImage_Click(object sender, EventArgs e)
        {
            AutoIT au3  = new AutoIT();
            IntPtr hWnd = IntPtr.Zero;

            // Find define handle of project
            hWnd = AutoControl.FindWindowHandle(null, textBoxTestID.Text);

            if (hWnd == IntPtr.Zero)
            {
                MessageBox.Show("Không tìm thấy nhân vật này đang được chạy.");
                return;
            }

            var imagePath = textBoxTestPath.Text;

            var screen = CaptureHelper.CaptureWindow(hWnd);

            screen.Save("test.png");
            Bitmap iBtn = ImageScanOpenCV.GetImage(imagePath);
            var    pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)screen, iBtn);

            if (pBtn != null)
            {
                au3.clickRight(textBoxTestID.Text, 1, pBtn.Value.X + int.Parse(numericUpDownTestX.Value.ToString()), pBtn.Value.Y + int.Parse(numericUpDownTestY.Value.ToString()));
                Thread.Sleep(Constant.TimeShort);
            }
        }
示例#4
0
        /*
         * Function: isMoving
         * Description: Kiểm tra nhân vật đang di chuyển
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-10 - Updated At: 2019-11-10
         */
        public bool isMoving()
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            int  i      = 0;
            bool moving = true;

            while (moving && i < Constant.MaxLoop && mCharacter.Running != 0)
            {
                // Chụp màn hình
                var screen_first = CaptureHelper.CaptureWindow(mHWnd);
                screen_first = CaptureHelper.CropImage((Bitmap)screen_first, new Rectangle(180, 0, 250, 250));

                // Chờ 3s
                Thread.Sleep(1500);
                var screen_second = CaptureHelper.CaptureWindow(mHWnd);

                // Kiểm tra hình trước có trong hình sau hay không
                var p = ImageScanOpenCV.FindOutPoint((Bitmap)screen_second, (Bitmap)screen_first);
                if (p != null)
                {
                    moving = false;
                    return(moving);
                }
            }

            return(moving);
        }
示例#5
0
        /// <summary>
        ///     Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
        /// </summary>
        /// <param name="ignoreFailedRegistration">
        ///     if true, a failed hotkey registration will not be reported to the user - the
        ///     hotkey will simply not be registered
        /// </param>
        /// <returns>
        ///     Whether the hotkeys could be registered to the users content. This also applies if conflicts arise and the
        ///     user decides to ignore these (i.e. not to register the conflicting hotkey).
        /// </returns>
        public bool RegisterHotkeys(bool ignoreFailedRegistration)
        {
            var success    = true;
            var failedKeys = new StringBuilder();

            if (!RegisterWrapper(failedKeys, "CaptureRegion", "RegionHotkey",
                                 () =>
            {
                CaptureHelper.CaptureRegion(true);
            }, ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureWindow", "WindowHotkey", () =>
            {
                if (_coreConfiguration.CaptureWindowsInteractive)
                {
                    CaptureHelper.CaptureWindowInteractive(true);
                }
                else
                {
                    CaptureHelper.CaptureWindow(true);
                }
            }, ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureFullScreen", "FullscreenHotkey",
                                 () => CaptureHelper.CaptureFullscreen(true, _coreConfiguration.ScreenCaptureMode), ignoreFailedRegistration))
            {
                success = false;
            }
            if (!RegisterWrapper(failedKeys, "CaptureLastRegion", "LastregionHotkey", () => CaptureHelper.CaptureLastRegion(true), ignoreFailedRegistration))
            {
                success = false;
            }
            if (_coreConfiguration.IECapture)
            {
                if (!RegisterWrapper(failedKeys, "CaptureIE", "IEHotkey", () =>
                {
                    if (_coreConfiguration.IECapture)
                    {
                        CaptureHelper.CaptureIe(true, null);
                    }
                }, ignoreFailedRegistration))
                {
                    success = false;
                }
            }

            if (!success && !ignoreFailedRegistration)
            {
                success = HandleFailedHotkeyRegistration(failedKeys.ToString());
            }

            return(success || ignoreFailedRegistration);
        }
示例#6
0
 private void CaptureWindow()
 {
     if (conf.CaptureWindowsInteractive)
     {
         CaptureHelper.CaptureWindowInteractive(true);
     }
     else
     {
         CaptureHelper.CaptureWindow(true);
     }
 }
示例#7
0
        public static Point?findGameImage(Bitmap image, string imageName = "", bool cropMode = false, int x = 0, int y = 0, int width = 0, int height = 0, bool capture = false)
        {
            var scene = CaptureHelper.CaptureWindow(Global.mainHandle);

            if (cropMode == true)
            {
                scene = CaptureHelper.CropImage(scene, new System.Drawing.Rectangle(x, y, width, height));
            }
            var result = ImageScanOpenCV.FindOutPoint((Bitmap)scene, image);

            if (capture == true && result != null)
            {
                var imageSave = ImageScanOpenCV.Find((Bitmap)scene, image);
                imageSave.Save("./img/debug/imageCapture" + result.Value.X + "_" + result.Value.Y + ".png");
            }
            return(result);
        }
示例#8
0
        private void Contextmenu_capturewindowfromlist_Click(object sender, EventArgs e)
        {
            var clickedItem = (ToolStripMenuItem)sender;

            BeginInvoke((MethodInvoker) delegate
            {
                try
                {
                    var windowToCapture = (InteropWindow)clickedItem.Tag;
                    CaptureHelper.CaptureWindow(windowToCapture);
                }
                catch (Exception exception)
                {
                    Log.Error().WriteLine(exception);
                }
            });
        }
示例#9
0
        private void Contextmenu_window_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;

            BeginInvoke((MethodInvoker) delegate
            {
                try
                {
                    WindowDetails windowToCapture = (WindowDetails)clickedItem.Tag;
                    CaptureHelper.CaptureWindow(windowToCapture);
                }
                catch (Exception exception)
                {
                    LOG.Error(exception);
                }
            });
        }
示例#10
0
        /*
         * Function: Find Image
         * Description: Find position of image on window
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-09 - Updated At: 2019-11-09
         */
        public bool findImage(string imagePath)
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            var    screen = CaptureHelper.CaptureWindow(mHWnd);
            Bitmap iBtn   = ImageScanOpenCV.GetImage(imagePath);
            var    pBtn   = ImageScanOpenCV.FindOutPoint((Bitmap)screen, iBtn);

            if (pBtn != null)
            {
                return(true);
            }

            return(false);
        }
示例#11
0
        /*
         * Function: Click to Image
         * Description: Find position of image on window and click it
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-09 - Updated At: 2019-11-09
         */
        public bool clickImage(Bitmap image, int xRange = 0, int yRange = -20, int numClick = 1, int wait = Constant.TimeShort)
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            var screen = CaptureHelper.CaptureWindow(mHWnd);
            var pBtn   = ImageScanOpenCV.FindOutPoint((Bitmap)screen, image);

            if (pBtn != null)
            {
                au3.click(mWindowName, numClick, pBtn.Value.X + xRange, pBtn.Value.Y + yRange);
                Thread.Sleep(wait);
                return(true);
            }
            return(false);
        }
示例#12
0
        /*
         * Function: Move mouse
         * Description: Find position of image on window and move mouse to it
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-09 - Updated At: 2019-11-09
         */
        public bool moveToImage(string imagePath, int xRange = 0, int yRange = -20)
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            var    screen = CaptureHelper.CaptureWindow(mHWnd);
            Bitmap iBtn   = ImageScanOpenCV.GetImage(imagePath);
            var    pBtn   = ImageScanOpenCV.FindOutPoint((Bitmap)screen, iBtn);

            if (pBtn != null)
            {
                au3.move(mWindowName, pBtn.Value.X + xRange, pBtn.Value.Y + yRange);
                return(true);
            }
            return(false);
        }
示例#13
0
        /*
         * Function: Click to Image
         * Description: Find position of image on window and click it
         * Author: Tử La Lan - Facebook: https://www.facebook.com/Tu.La.Lan.NT
         * Created At: 2019-11-09 - Updated At: 2019-11-09
         */
        public bool clickRightToImage(string imagePath, int xRange = 0, int yRange = -20)
        {
            if (mCharacter.Running == 0)
            {
                return(false);
            }

            var    screen = CaptureHelper.CaptureWindow(mHWnd);
            Bitmap iBtn   = ImageScanOpenCV.GetImage(imagePath);
            var    pBtn   = ImageScanOpenCV.FindOutPoint((Bitmap)screen, iBtn);

            if (pBtn != null)
            {
                au3.clickRight(mWindowName, 1, pBtn.Value.X + xRange, pBtn.Value.Y + yRange);
                Thread.Sleep(Constant.TimeShort);
                return(true);
            }
            return(false);
        }
示例#14
0
        public static Point?findExpMonster()
        {
            int   i = 0;
            Point?expMonsterImage = null;
            Image scene           = null;;

            GameHelper.Log("Finding exp monster....");
            while (i < 5)
            {
                scene           = CaptureHelper.CaptureWindow(Global.mainHandle);
                expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, expImage);
                //expMonsterImage = GameImage.findGameImage(expImage);
                if (expMonsterImage != null)
                {
                    GameHelper.Log("Found Exp Monster(Middle)!!!");
                    break;
                }
                expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, nearExpImage);
                if (expMonsterImage != null)
                {
                    GameHelper.Log("Found Exp Monster(Near)!!!");
                    break;
                }
                expMonsterImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, farExpImage);
                if (expMonsterImage != null)
                {
                    GameHelper.Log("Found Exp Monster(Far)!!!");
                    break;
                }
                i++;
                GameHelper.Delay(200);
            }
            if (expMonsterImage == null)
            {
                GameHelper.Log("Found Exp Monster Fail!!!");
            }
            return(expMonsterImage);
        }
示例#15
0
        private void button18_Click(object sender, EventArgs e)
        {
            var handle = AutoControl.FindWindowHandle("LDMultiPlayerMainFrame" == "" ? null : "LDMultiPlayerMainFrame", "" == "" ? null : "");

            #region // khởi tạo và restore file backup


            #endregion

            #region // ấn nút bắt đầu
            var sub   = (Bitmap)Bitmap.FromFile("data//data.png");
            var main  = (Bitmap)CaptureHelper.CaptureWindow(handle);
            var point = ImageScanOpenCV.FindOutPoint(main, sub);
            if (point != null)
            {
                //   AutoControl.SendClickOnPosition(handle, point.Value.X, point.Value.Y);
                var       pointToClick = AutoControl.GetGlobalPoint(handle, point.Value.X + 7, point.Value.Y + 5);
                EMouseKey mouseKey     = EMouseKey.DOUBLE_LEFT;
                AutoControl.BringToFront(handle);
                AutoControl.MouseClick(pointToClick, mouseKey);
            }
            #endregion
        }
示例#16
0
        public static List <int> findMultiGameImage(Bitmap[] images, bool cropMode = false, int x = 0, int y = 0, int width = 0, int height = 0, bool capture = false)
        {
            List <int> result = new List <int>();
            var        scene  = CaptureHelper.CaptureWindow(Global.mainHandle);

            if (cropMode == true)
            {
                scene = CaptureHelper.CropImage(scene, new System.Drawing.Rectangle(x, y, width, height));
            }
            var   index = 0;
            Point?resultScanImage;

            foreach (Bitmap image in images)
            {
                resultScanImage = null;
                resultScanImage = ImageScanOpenCV.FindOutPoint((Bitmap)scene, image);
                if (resultScanImage != null)
                {
                    result.Add(index);
                }
                index++;
            }
            return(result);
        }
示例#17
0
        /// <inheritdoc />
        public void Capture(string parameters)
        {
            if (MainForm.Instance.InvokeRequired)
            {
                MainForm.Instance.Invoke((MethodInvoker)(() => Capture(parameters)));
                return;
            }

            Log.Info().WriteLine("Capture requested: {0}", parameters);

            string[] optionsArray = parameters.Split(',');
            string   captureMode  = optionsArray[0];
            // Fallback-Destination

            var designation = _coreConfiguration.OutputDestinations.FirstOrDefault();
            var destination = _destinationHolder.SortedActiveDestinations.FirstOrDefault(d => d.Designation == designation);

            switch (captureMode.ToLower())
            {
            case "region":
                CaptureHelper.CaptureRegion(false, destination);
                break;

            case "window":
                CaptureHelper.CaptureWindow(false, destination);
                break;

            case "fullscreen":
                CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen, destination);
                break;

            default:
                Log.Warn().WriteLine("Unknown capture option");
                break;
            }
        }
示例#18
0
        private void buttonTestCapturePosition_Click(object sender, EventArgs e)
        {
            IntPtr hWnd = IntPtr.Zero;

            // Find define handle of project
            hWnd = AutoControl.FindWindowHandle(null, textBoxTestID.Text);

            if (hWnd == IntPtr.Zero)
            {
                MessageBox.Show("Không tìm thấy nhân vật này đang được chạy.");
            }

            var imagePath = textBoxTestPath.Text;

            // Chụp màn hình
            var full_screen = CaptureHelper.CaptureWindow(hWnd);

            Bitmap        iBtn = ImageScanOpenCV.GetImage(imagePath);
            var           pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)full_screen, iBtn);
            List <Bitmap> pos  = new List <Bitmap>();

            //if (pBtn != null)
            //{
            //    pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-15), pBtn.Value.Y + (-30), 30, 30)));
            //    pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (11), pBtn.Value.Y + (0), 30, 30)));
            //    pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-15), pBtn.Value.Y + (20), 30, 30)));
            //    pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-32), pBtn.Value.Y + (0), 30, 30)));
            //}
            //pictureBoxTest1.Image = pos[0];
            //pictureBoxTest2.Image = pos[1];
            //pictureBoxTest3.Image = pos[2];
            //pictureBoxTest4.Image = pos[3];

            //MessageBox.Show(pos.Count.ToString());

            // top: x -15, y -30
            // left: x -30, y 0
            // down: x -15, y 20
            // right: x 11, y 0
            // Click: x 15, y -15



            if (pBtn != null)
            {
                int x_start_point = pBtn.Value.X + 0;
                int y_start_point = pBtn.Value.Y + 60;
                for (int y = 0; y < 4; y++)
                {
                    for (int x = 0; x < 4; x++)
                    {
                        pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(
                                                            x_start_point + (x * 100),
                                                            y_start_point + (y * 70),
                                                            100, 70)));
                    }
                }
            }

            MessageBox.Show(pos.Count.ToString());

            // screen: h 60, w 100

            // h: 280, w: 400

            // h: 40 * 7, w: 80 * 5
            for (int z = 0; z < pos.Count; z++)
            {
                var picture = new PictureBox
                {
                    Name     = "pictureBox",
                    Size     = new Size(100, 70),
                    Location = new Point(300 + z * 100, 100 + z * 70),
                    Image    = pos[z],
                };
                this.Controls.Add(picture);
            }
        }
 public static void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)
 {
     CaptureHelper.CaptureWindow(handle).Save(filename, format);
 }
 public static Image CaptureScreen()
 {
     return(CaptureHelper.CaptureWindow(CaptureHelper.User32.GetDesktopWindow()));
 }
示例#21
0
 private Bitmap RetakePicMain()
 {
     return((Bitmap)CaptureHelper.CaptureWindow(hw));
 }
示例#22
0
        public void chayQ()
        {
            // Xóa ghi chép chat
            mAuto.clickImageByGroup("global", "chatclear", false, true);

            List <Bitmap> pos = new List <Bitmap>();

            int loop = 0;

            while (!checkDaDanhNhiemVu())
            {
                loop++;
                if (loop >= 5)
                {
                    Helper.showAlert(mCharacter.ID, "Nhiệm vụ phi tặc này có vấn đề");
                }

                // Mở menu phải
                mAuto.moMenuPhai();

                // Nếu vip dưới 6 thì mới chạy cái này
                if (mCharacter.VipLevel < 6 && mCharacter.VipLevel > 0)
                {
                    // Bay
                    mAuto.bay();
                }

                // Tìm tới tọa độ và gọi quái
                while (!checkDaGoiQuai())
                {
                    // Mở túi nhiệm vụ
                    mAuto.closeAllDialog();
                    mAuto.clickToImage(Constant.ImagePathGlobalTui);
                    mAuto.clickImageByGroup("global", "tui_tab_nhiemvu", true, true);

                    // Nhấp đôi vào bản đồ nhiệm vụ
                    mAuto.clickToImage(Constant.ImagePathTriAnBanDoNhiemVu, 0, -20, 2);

                    // Chờ 2s để load map
                    Thread.Sleep(2000);

                    mAuto.closeAllDialog();

                    // Nếu vip dưới 6 thì mới chạy cái này
                    if (mCharacter.VipLevel < 6 && mCharacter.VipLevel > 0)
                    {
                        do
                        {
                            // Nhấp vào tọa độ
                            mAuto.writeStatus("Nhấp vào tọa độ ...");
                            mAuto.clickToImage(Constant.ImagePathTriAnToaDo, 10, -25);
                            mAuto.clickToImage(Constant.ImagePathTriAnToaDo2, 10, -25);
                        } while (mAuto.isMoving());
                    }

                    var full_screen = CaptureHelper.CaptureWindow(mHWnd);

                    // Lưu tracking
                    Bitmap bChuyenKenh  = ImageScanOpenCV.GetImage(Constant.ImagePathGlobalChuyenKenh);
                    var    pBChuyenKenh = ImageScanOpenCV.FindOutPoint((Bitmap)full_screen, bChuyenKenh);

                    if (pBChuyenKenh != null)
                    {
                        Bitmap tracking = CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBChuyenKenh.Value.X, pBChuyenKenh.Value.Y, 180, 20));
                        tracking.Save("tracking/trian_" + mCharacter.ID + ".png", ImageFormat.Png);
                    }
                }

                mAuto.closeAllDialog();

                // Nếu vip dưới 6 thì mới chạy cái này
                if (mCharacter.VipLevel < 6 && mCharacter.VipLevel > 0)
                {
                    // Xuống
                    mAuto.bayXuong();
                }

                // Đóng menu phải
                mAuto.dongMenuPhai();

                // Tìm phản quân hoặc phi tặc
                int x = 0;
                while (!mAuto.findImage(Constant.ImagePathDoiThoai + "trian" + ".png") && x < lPTPQ.Count)
                {
                    if (mAuto.findImage(lPTPQ[x].imagePath))
                    {
                        mAuto.clickToImage(lPTPQ[x].imagePath, lPTPQ[x].x, lPTPQ[x].y);
                    }

                    x++;
                }

                // Đánh
                mAuto.clickToImage(Constant.ImagePathDoiThoai + "trian" + ".png");

                // Nghỉ 5s nếu nhân vật đang trong trận đấu
                while (mAuto.dangTrongTranDau())
                {
                    Thread.Sleep(5000);
                }

                if (checkDaDanhNhiemVu())
                {
                    break;
                }

                // Lưu 4 vị trí xung quanh vị trí hiện tại
                if (pos.Count <= 0)
                {
                    // Mở bảng đồ mini
                    mAuto.clickToImage(Constant.ImagePathMiniMap);

                    Thread.Sleep(1000);

                    var full_screen = CaptureHelper.CaptureWindow(mHWnd);

                    // Tắt các bảng nổi
                    mAuto.closeAllDialog();

                    // Lưu 4 vị trí
                    Bitmap iBtn = ImageScanOpenCV.GetImage(Constant.ImagePathInMapChar);
                    var    pBtn = ImageScanOpenCV.FindOutPoint((Bitmap)full_screen, iBtn);

                    if (pBtn != null)
                    {
                        pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-15), pBtn.Value.Y + (-30), 30, 30)));
                        pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (11), pBtn.Value.Y + (0), 30, 30)));
                        pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-15), pBtn.Value.Y + (20), 30, 30)));
                        pos.Add(CaptureHelper.CropImage((Bitmap)full_screen, new Rectangle(pBtn.Value.X + (-32), pBtn.Value.Y + (0), 30, 30)));
                    }
                }

                // Di chuyển đến vị trí quanh ptpq
                int i = 0;
                while (!mAuto.findImage(Constant.ImagePathDoiThoai + "trian" + ".png") && i < pos.Count)
                {
                    // Mở menu phải
                    mAuto.moMenuPhai();

                    // Bay lên
                    mAuto.bay();

                    // Mở bảng đồ mini
                    mAuto.clickToImage(Constant.ImagePathMiniMap);

                    // Nhấp vào vị trí xung quanh ptpq
                    mAuto.clickImage(pos[i], 15, -15);

                    // Tắt các bảng nổi
                    mAuto.closeAllDialog();

                    // Đóng menu phải
                    mAuto.dongMenuPhai();

                    // Tìm phản quân hoặc phi tặc
                    int y = 0;
                    while (!mAuto.findImage(Constant.ImagePathDoiThoai + "trian" + ".png") && y < lPTPQ.Count)
                    {
                        if (mAuto.findImage(lPTPQ[y].imagePath))
                        {
                            // Mở menu phải
                            mAuto.moMenuPhai();

                            // Bay xuống
                            if (mAuto.findImage(Constant.ImagePathGlobalXuong))
                            {
                                mAuto.bayXuong();
                                Thread.Sleep(3000);
                            }

                            // Đóng menu phải
                            mAuto.dongMenuPhai();

                            mAuto.clickToImage(lPTPQ[y].imagePath, lPTPQ[y].x, lPTPQ[y].y);
                            Thread.Sleep(1000);
                        }

                        y++;
                    }

                    i++;
                }

                // Đánh
                mAuto.clickToImage(Constant.ImagePathDoiThoai + "trian" + ".png");

                // Nghỉ 5s nếu nhân vật đang trong trận đấu
                while (mAuto.dangTrongTranDau())
                {
                    Thread.Sleep(5000);
                }
            }

            if (!checkHoanThanhNhiemVu())
            {
                // Nhấn vào nhận Q Trị An
                mAuto.clickImageByGroup("tri_an", "nhiemvutrianchuanhan", false, true);
                mAuto.clickImageByGroup("tri_an", "nhiemvuphanquandaxong", false, true);
                mAuto.clickImageByGroup("tri_an", "nhiemvuphitacdaxong", false, true);
                // Trả nhiệm vụ
                mAuto.traNhiemVu();
            }
        }