Exemplo n.º 1
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_format">字的颜色</param>
        /// <param name="ran1">随机数X=随机数(0,最大坐标-找到的X坐标)</param>
        /// <param name="ran2">随机数Y=随机数(0,最大坐标-找到的Y坐标)</param>
        /// <param name="sim"></param>
        /// <returns>返回1成功,0失败</returns>
        public static bool FindStrE_LeftClick(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color_format, int ran1 = 0, int ran2 = 0, double sim = 1.0)
        {
            string s = "";
            string picX, picY;

            s = dm.FindStrE(x1, y1, x2, y2, str, color_format, sim);
            if (s != "-1|-1|-1")
            {
                string[] picList_Split = s.Split('|');
                picX = picList_Split[1];
                picY = picList_Split[2];
                int x, y;
                x = int.Parse(picX);
                y = int.Parse(picY);
                dm.MoveTo(x + ran1, y + ran2);
                System.Threading.Thread.Sleep(dm.RanNumber(50, 100));
                dm.LeftClick();
                dm.MoveTo(0, 0);
                return(true);
            }
            else
            {
                Logger.Info("未找到字:" + str);
                return(false);
            }
        }
Exemplo n.º 2
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="pic_name"></param>
        /// <param name="ran1">随机数X=随机数(0,最大坐标-找到的X坐标)</param>
        /// <param name="ran2">随机数Y=随机数(0,最大坐标-找到的Y坐标)</param>
        /// <returns>返回1成功,0失败</returns>
        public static bool FindStrE_LeftClick_Clear(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color, int ran1, int ran2, double sim = 1.0)
        {
            int    strX    = 0;
            int    strY    = 0;
            string strList = "";

            strList = dm.FindStrE(x1, y1, x2, y2, str, color, sim);
            if (strList != "-1|-1|-1")
            {
                while (true)
                {
                    strList = dm.FindStrE(x1, y1, x2, y2, str, color, sim);
                    if (strList != "-1|-1|-1")
                    {
                        Logger.Info("找到字" + str);
                        if (strList.Equals(""))
                        {
                            throw new Exception("请先进行注册!");
                        }
                        string[] picList_Split = strList.Split('|');
                        strX = int.Parse(picList_Split[1]);
                        strY = int.Parse(picList_Split[2]);
                        dm.MoveTo(strX + ran1, strY + ran2);
                        dm.LeftClick();
                        dm.MoveTo(1, 1);
                    }
                    else
                    {
                        return(true);
                    }
                    System.Threading.Thread.Sleep(dm.RanNumber(500, 600));
                }
            }
            else
            {
                return(false);
            }
        }