/// <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> /// 找图,返回图片坐标 比如"0|100|200" /// </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="Second">如果true,则1秒扫5次</param> /// <returns>返回空表示没找到图片</returns> public static string FindPicE(this DmPlugin dm, int x1, int y1, int x2, int y2, string pic_name, bool Second = true) { string picList = ""; int index = 0; if (Second == true) { while (Second == true) { picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", 0.9, 0); if (picList != "-1|-1|-1") { return(picList); } else { System.Threading.Thread.Sleep(200); index = index + 1; if (index == 5) { return(""); } else { break; } } } return(""); } else { picList = dm.FindPicE(x1, y1, x2, y2, pic_name, "000000", 0.9, 0); if (picList != "-1|-1|-1") { return(picList); } else { return(picList); } } }
/// <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); } }
/// <summary> /// 商城界面是否有某个物品 /// </summary> /// <param name="role"></param> /// <param name="name">物品的名字</param> /// <returns></returns> public static bool HasMallThing(this IRole role, string name) { DmPlugin dm = role.Window.Dm; return(dm.FindPicE(0, 0, role.Window.Width, role.Window.Height, name + ".bmp") == ""?false:true); }