Esempio 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="pic_name"></param>
        /// <param name="ran1">随机数X=随机数(0,最大坐标-找到的X坐标)</param>
        /// <param name="ran2">随机数Y=随机数(0,最大坐标-找到的Y坐标)</param>
        /// <param name="Second">如果true,则1秒扫5次</param>
        /// <returns>返回1成功,0失败</returns>
        public static bool FindPicE_LeftClick(this DmPlugin dm, int x1, int y1, int x2, int y2, string pic_name, int ran1 = 0, int ran2 = 0, bool Second = true)
        {
            string picList = "";
            int    index   = 0;
            int    PicX    = 0; //图片左上角X
            int    PicY    = 0; //图片左上角Y

            if (Second == true)
            {
                while (Second == true)
                {
                    picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", 0.9, 0);
                    if (picList != "-1|-1|-1")
                    {
                        string[] picList_Split = picList.Split('|');
                        PicX = int.Parse(picList_Split[1]);
                        PicY = int.Parse(picList_Split[2]);
                        dm.MoveTo(PicX + ran1, PicY + ran2);
                        System.Threading.Thread.Sleep(dm.RanNumber(50, 100));
                        dm.LeftClick();
                        return(true);
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(200);
                        index = index + 1;
                        if (index == 5)
                        {
                            Logger.Info("未找到图片:" + pic_name);
                            return(false);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                Logger.Info("未找到图片:" + pic_name);
                return(false);
            }
            else
            {
                picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", 0.9, 0);
                if (picList != "-1|-1|-1")
                {
                    string[] picList_Split = picList.Split('|');
                    PicX = int.Parse(picList_Split[1]);
                    PicY = int.Parse(picList_Split[2]);
                    dm.MoveTo(PicX + ran1, PicY + ran2);
                    System.Threading.Thread.Sleep(dm.RanNumber(50, 100));
                    dm.LeftClick();
                    return(true);
                }
                else
                {
                    Logger.Info("未找到图片:" + pic_name);
                    return(false);
                }
            }
        }
Esempio 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="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);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 使用系统字库宋体9下划线,查找字符串,并点击
        /// </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="sim"></param>
        /// <returns></returns>
        public static bool FindStrWithFont_LeftClick_St9_(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color, int w, int h, double sim = 1.0)
        {
            int intX, intY;

            dm.FindStrWithFont(x1, y1, x2, y2, str, color, sim, "宋体", 9, 4, out intX, out intY);
            if (intX >= 0 && intY >= 0)
            {
                dm.MoveTo(intX + w, intY + h);
                dm.LeftClick();
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// 鼠标位置是否有指定控件文本
        /// </summary>
        /// <param name="role"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="isClick"></param>
        /// <returns></returns>
        public static bool FindControlTextAndClick(this IRole role, int x, int y, string text, bool isClick = false)
        {
            DmPlugin dm   = role.Window.Dm;
            int      hwnd = role.Window.Hwnd;

            dm.MoveTo(x, y);
            dm.Delay(200);
            string content = dm.ReadString(hwnd, "[16cbc90]+30", 1, 10);

            //  Debug.WriteLine(content);
            if (content.Contains(text))
            {
                if (isClick)
                {
                    dm.LeftClick();
                }
                return(true);
            }
            return(false);
        }
Esempio 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="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);
            }
        }
Esempio n. 6
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 FindPicE_LeftClick_Clear(this DmPlugin dm, int x1, int y1, int x2, int y2, string pic_name, int ran1, int ran2, double sim = 0.9)
        {
            int    PicX    = 0; //图片左上角X
            int    PicY    = 0; //图片左上角Y
            string picList = "";

            picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", sim, 0);
            if (picList != "-1|-1|-1")
            {
                while (true)
                {
                    picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", sim, 0);
                    if (picList != "-1|-1|-1")
                    {
                        Logger.Info("找到图片" + pic_name);
                        if (picList.Equals(""))
                        {
                            throw new Exception("请先进行注册!");
                        }
                        string[] picList_Split = picList.Split('|');
                        PicX = int.Parse(picList_Split[1]);
                        PicY = int.Parse(picList_Split[2]);
                        dm.MoveTo(PicX + ran1, PicY + ran2);
                        dm.LeftClick();
                        dm.MoveTo(1, 1);
                    }
                    else
                    {
                        return(true);
                    }
                    System.Threading.Thread.Sleep(dm.RanNumber(500, 600));
                }
            }
            else
            {
                return(false);
            }
        }