Exemplo n.º 1
0
        public bool OpenHuodong()
        {
            int intX, intY;

            _dm.FindStr(258, 34, 854, 218, "活动", "C09755-27413C", 0.9, out intX, out intY);
            if (intX > 0 && intY > 0)
            {
                _dm.MoveToClick(intX, intY);
                _dm.Delay(1000);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public static bool FindStr(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color, double sim = 1.0)
        {
            int intX, intY;

            dm.FindStr(x1, y1, x2, y2, str, color, sim, out intX, out intY);
            if (intX >= 0 && intY >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查找区域是否存在指定图片
        /// </summary>
        /// <param name="_dm"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="str"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public static bool IsExistStr(this DmPlugin _dm, int x1, int y1, int x2, int y2, string str, string color)
        {
            int intX, intY;

            _dm.FindStr(x1, y1, x2, y2, str, color, 0.8, out intX, out intY);
            if (intX > 0 && intY > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 找到某字符串后返回相同行ocr的字符串
        /// </summary>
        /// <param name="dm"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="str"></param>
        /// <param name="color"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="ocrColor"></param>
        /// <param name="sim"></param>
        /// <returns></returns>
        public static string FindStr_Ocr(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color, int w, int h, string ocrColor, double sim = 1.0)
        {
            int intX, intY;
            int ret = dm.FindStr(x1, y1, x2, y2, str, color, sim, out intX, out intY);

            if (intX >= 0 && intY >= 0)
            {
                return(dm.OCR(intX, intY - 5, intX + w, intY + h, ocrColor, 0.9));
            }
            else
            {
                Logger.Debug("未找到字:" + str);
                return("");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 查找指定区域是否存在字,存在则点击字,可设置偏移
        /// </summary>
        /// <param name="_dm"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="str"></param>
        /// <param name="color"></param>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static bool FindStrAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string str, string color, int a = 0, int b = 0)
        {
            int intX, intY;

            _dm.FindStr(x1, y1, x2, y2, str, color, 0.8, out intX, out intY);
            if (intX > 0 && intY > 0)
            {
                //Debug.WriteLine("找字[" + str + "]成功!");
                _dm.MoveToClick(intX + a, intY + b);
                _dm.Delay(50);
                return(true);
            }

            Debug.WriteLine("[" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + "找字[" + str + "]失败!");
            return(false);
        }
Exemplo n.º 6
0
        private TaskResult RunStep1(TaskContext context)
        {
            Role     role = (Role)context.Role;
            DmPlugin dm   = role.Window.Dm;

            role.GoToMap("世界");
            role.CloseWindow();
            dm.Delay(1000);
            if (Dm.IsExistPic(862, 454, 961, 537, @"\bmp\菜单打开.bmp"))
            {
                Delegater.WaitTrue(() => Dm.FindPicAndClick(862, 454, 961, 537, @"\bmp\菜单打开.bmp"),
                                   () => Dm.IsExistPic(862, 454, 961, 537, @"\bmp\菜单未打开.bmp"),
                                   () => Dm.Delay(1000), 2000);
            }
            role.OpenMap();

            int intX, intY;

            while (true)
            {
                dm.FindStr(75, 246, 227, 296, "军资奖励", "44.34.64-10.10.25", 0.9, out intX, out intY);
                if (intX > 0 && intY > 0)
                {
                    role.OutSubMessage("领取军资...");
                    dm.MoveToClick(156, 420);
                    dm.Delay(50);
                    if (dm.GetColorNum(157, 242, 227, 293, "f60000-101010", 0.9) > 5)
                    {
                        role.OutSubMessage("军资已经领取完成,正在冷却!");
                        break;
                    }
                    dm.Delay(300);
                }
                else
                {
                    role.OutSubMessage("找不到军资奖励");
                    break;
                }
            }

            role.CloseMap();

            return(TaskResult.Success);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 是否有打开面板
        /// </summary>
        /// <param name="role"></param>
        /// <param name="boardName"></param>
        /// <returns></returns>
        public static bool HasBoard(this IRole role, string boardName)
        {
            DmPlugin dm = role.Window.Dm;

            return(dm.FindStr(0, 0, role.Window.Width, role.Window.Height, boardName, "bebebe-414141"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 是否有对话框
        /// </summary>
        /// <param name="role"></param>
        /// <param name="boardName"></param>
        /// <returns></returns>
        public static bool HasDialogBoard(this IRole role, string boardName)
        {
            DmPlugin dm = role.Window.Dm;

            return(dm.FindStr(0, 0, 2000, 2000, boardName, "BEBEBE-414141", 0.9));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 是否有按钮
        /// </summary>
        /// <param name="role"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool HasButton(this IRole role, string name)
        {
            DmPlugin dm = role.Window.Dm;

            return(dm.FindStr(0, 0, 2000, 2000, name, "BEBEBE-414141", 0.9));
        }
Exemplo n.º 10
0
        private TaskResult RunStep1(TaskContext context)
        {
            IRole    role = context.Role;
            Role     r    = (Role)role;
            DmPlugin dm   = role.Window.Dm;
            int      hwnd = role.Window.Hwnd;

            // if(!role.HasButton("搜索"))  //商城界面是否打开
            //    throw new TaskInterruptException("请先打开商城界面.");

            if (_useLB)
            {
                if (!_thing.CanUseLB)
                {
                    throw new TaskInterruptException("“{0}”无法使用龙币购买.".FormatWith(_thing.Name));
                }
                if (r.MallLB < _thing.Value)
                {
                    throw new TaskInterruptException("龙币不足,无法购买物品“{0}”.".FormatWith(_thing.Name));
                }
            }
            else
            {
                if (r.MallVolume < _thing.Value)
                {
                    throw new TaskInterruptException("点卷不足,无法购买物品“{0}”.".FormatWith(_thing.Name));
                }
            }

            bool ret = Delegater.WaitTrue(() =>
            {
                dm.MoveToClick(567, 43);
                dm.SendString(hwnd, _thing.Name);
                dm.MoveToClick(766, 43);
                return(true);
                // return role.HasButton("购买") ? true : false;
            }, () => dm.Delay(1000), 10);

            if (ret == false)
            {
                return(new TaskResult(TaskResultType.Failure, "无法找到该商品“{0}”.".FormatWith(_thing.Name)));
            }
            role.FindButtonAndClick("购买");
            dm.Delay(500);
            //  if (role.HasDialogBoard("结算"))
            // {
            if (_useLB)
            {
                dm.MoveToClick(937, 572);
            }
            dm.Delay(500);
            // Delegater.WaitTrue(() => role.HasDialogButton("是"),()=>dm.MoveToClick(608,718));
            // Delegater.WaitTrue(() => !role.HasDialogButton("是"),()=>dm.MoveToClick(508,537));
            dm.MoveToClick(608, 718);
            dm.Delay(500);
            dm.MoveToClick(508, 537);
            Delegater.WaitTrue(() => dm.FindStr(629, 459, 850, 560, "确认", "BEBEBE-414141", 0.9), () => dm.Delay(100));
            // Delegater.WaitTrue(() => !role.HasDialogButton("确认"), () => dm.MoveToClick(719,506));
            dm.MoveToClick(719, 506);
            //  }
            _num--;
            return(_num <= 0? TaskResult.Finished : RunStep1(context));
        }