/// <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); } } }
/// <summary> /// 防封,移动鼠标单击 /// </summary> /// <param name="dm"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static bool PMoveToClick(this DmPlugin dm, int x, int y) { int flag = dm.MoveTo(x, y); dm.Delay(dm.RanNumber(50, 200)); int a = dm.LeftDown(); dm.Delay(dm.RanNumber(50, 200)); int sjx = dm.RanNumber(1, 5); int sjy = dm.RanNumber(1, 5); int b = dm.MoveTo(x + sjx, y + sjy); int c = dm.LeftUp(); return(a == 1 && b == 1 && c == 1 && flag == 1 ? true : false); }
/// <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); } }
/// <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); } }
/// <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); } }