/// <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); } }
private TaskResult RunStep1(TaskContext context) { IRole role = context.Role; DmPlugin dm = role.Window.Dm; int hwnd = role.Window.Hwnd; dm.MoveToClick(97, 829); for (int i = 0; i < 50; i++) { dm.MoveTo(512 + i, 416); } //Locator.Teleport.Teleport(new Point() { Name = "进图入口", X = -1356.5f, Y = -1791.6f, Z = 15.5f }); //dm.Delay(2000); //dm.MoveToClick(910, 701); //入场 //dm.Delay(10000); //Locator.Teleport.Teleport(new Point() { Name = "第四关入口", X = 4661.5f, Y = 4338.5f, Z = -110.6f }); //dm.MoveToRightClick(335, 825); //月光碎片 //dm.Delay(14000); //Locator.Teleport.Teleport(new Point() { Name = "Boss输出坐标", X = 1793f, Y = 2434f, Z = -1012f }); //dm.MoveToRightClick(224, 825); //致命劈砍 //dm.Delay(14000); //dm.MoveToRightClick(722, 825); //水月神舞 //dm.Delay(2000); //Locator.Teleport.Teleport(new Point() { Name = "安全坐标", X = 50000f, Y = 50000f, Z = 0f }); //dm.MoveToRightClick(832, 825); //Delegater.WaitTrue(() => dm.FindStr(229, 175, 1103, 511, "箱子1", "ffffff-222222"), () => dm.Delay(1000), 120); //dm.Delay(18000); //Locator.Teleport.Teleport(new Point() { Name = "箱子坐标", X = 1641.3f, Y = 2322.4f, Z = -1012 }); //dm.WriteFloat(hwnd, "440404B4",10f); //dm.LeftClick(); //dm.Delay(5000); return(TaskResult.Finished); }
private void TaskStart() { TaskRunState = TaskRunState.Started; DmPlugin dm = Window.Dm; if (Window.Width != 1152 || Window.Height != 864) { throw new Exception("请将游戏分辨率设为1152*864!"); } bool flag = Delegater.WaitTrue(() => Window.BindFullBackground(), // dm.BindWindow(Window.Hwnd,DmBindDisplay.dx,DmBindMouse.windows,DmBindKeypad.normal,0)==1?true:false, () => dm.Delay(1000), 10); dm.Delay(500); if (!flag) { throw new Exception(string.Format("窗口“{0}”绑定失败.", Window.Title)); } else { Logger.Debug("窗口绑定成功!"); Window.IsBind = true; } TaskRunState = TaskRunState.Running; DoEventHandler(OnStateChanged, _taskEventArg); DoEventHandler(OnStarted, _taskEventArg); Logger.Debug("任务“{0}”启动成功.".FormatWith(_task.Name)); TaskResult result = null; try { result = _task.Run(); } catch (TaskRestartException ex) { Logger.Error("任务执行错误,正在重新启动:" + ex.Message); TaskStop(); TaskStart(); } catch (TaskInterruptException ex) { TaskStop(); Window.FlashWindow(); _workThread = null; SoftContext.MainWindow.ShowMessageAsync("任务中断", ex.Message); } if (result == null) { return; } if (result.ResultType == TaskResultType.Success) { SoftContext.MainWindow.ShowMessageAsync("任务完成", "任务“{0}”执行完毕:{1}".FormatWith(_task.Name, result.Message)); } if (result.ResultType == TaskResultType.Finished) { SoftContext.MainWindow.ShowMessageAsync("任务完成", "任务“{0}”执行结束,{1}".FormatWith(_task.Name, result.Message)); } }
/// <summary> /// 二值化Bitmap /// </summary> /// <param name="dm"></param> /// <param name="filePath"></param> /// <param name="newFilePath"></param> public static void Binarization(this DmPlugin dm, string filePath, string newFilePath) { Bitmap btmp = new Bitmap(filePath); BitmapData btmpd = btmp.LockBits(new Rectangle(0, 0, btmp.Width, btmp.Height), ImageLockMode.ReadWrite, btmp.PixelFormat); //32位深度为4,24位为3 int PixelSize = 3; unsafe { for (int i = 0; i < btmp.Height; i++) { for (int j = 0; j < btmp.Width; j++) { // ded8c7 byte *row = (byte *)btmpd.Scan0 + PixelSize * j + (i * btmpd.Stride); if (row[0] + row[1] + row[2] > 382) { // if(row[0]!=(int)0xde&&row[1]!=(int)0xd8&&row[2]!=(int)0xc7) row[0] = row[1] = row[2] = 255; continue; } row[0] = row[1] = row[2] = 0; } } } btmp.Save(newFilePath); }
/// <summary> /// 利用 GetScreenData 截图,并体现在 pictureBox 上 /// </summary> /// <param name="dm">大漠对象</param> /// <param name="x1">截图左上角X</param> /// <param name="y1">截图左上角Y</param> /// <param name="x2">截图右下角X</param> /// <param name="y2">截图右下角Y</param> /// <returns></returns> public static Bitmap GetBitMap(this DmPlugin dm, int x1, int y1, int x2, int y2) { int bmpdata = dm.GetScreenData(x1, y1, x2, y2); Logger.Info(bmpdata); int width = x2 - x1; int size = (x2 - x1) * (y2 - y1); Bitmap bmp = new Bitmap(x2 - x1, y2 - y1); Color c; for (int i = 0; i < size; i++) { int bb = System.Runtime.InteropServices.Marshal.ReadByte((IntPtr)(bmpdata + i * 4)); int gg = System.Runtime.InteropServices.Marshal.ReadByte((IntPtr)(bmpdata + i * 4 + 1)); int rr = System.Runtime.InteropServices.Marshal.ReadByte((IntPtr)(bmpdata + i * 4 + 2)); c = Color.FromArgb(rr, gg, bb); //备用方案 上述方案生成不成功选用下面的 //int cc = System.Runtime.InteropServices.Marshal.ReadInt32((IntPtr)(bmpdata + i * 4)); //c = Color.FromArgb(cc); bmp.SetPixel(i % width, i / width, c); } // System.Runtime.InteropServices.Marshal.FreeHGlobal((IntPtr)bmpdata); return(bmp); }
public static OperationResult <DmSystem> GetDmSystem(string dmPath = "dm.dll") { if (!File.Exists(dmPath)) { return(new OperationResult <DmSystem>(OperationResultType.Error, $"大漠插件文件“{dmPath}”不存在")); } DmPlugin dm = new DmPlugin(dmPath); Version ver = new Version(dm.Ver()); if (ver > new Version("3.1233")) { string code = SoftContext.Locator.Settings.DmRegCode; if (code == null) { return(new OperationResult <DmSystem>(OperationResultType.Error, "大漠插件版本大于“3.1233”,请在“菜单-设置”中设置大漠注册码")); } int ret = dm.Reg(code); if (ret != 1) { return(new OperationResult <DmSystem>(OperationResultType.Error, $"大漠插件版本大于“3.1233”,执行插件注册失败,失败码:{ret}")); } } DmSystem system = new DmSystem(dm); return(new OperationResult <DmSystem>(OperationResultType.Success, "大漠系统对象获取成功", system)); }
private static async Task ResolveDmPlugin() { SettingsViewModel model = SoftContext.Locator.Settings; if (!File.Exists(model.DmFile)) { await SoftContext.ShowMessageAsync("错误", $"指定大漠路径“{model.DmFile}”的文件不存在"); return; } try { DmPlugin dm = new DmPlugin(model.DmFile); Version ver = new Version(dm.Ver()); model.DmVersion = ver.ToString(); model.DmVersionShow = true; model.DmRegCodeShow = ver > new Version("3.1233"); SoftContext.DmSystem = new DmSystem(dm); } catch (Exception ex) { await SoftContext.MainWindow.Dispatcher.Invoke(async() => { await SoftContext.ShowMessageAsync("错误", $"大漠初始化错误:{ex.Message}"); }); model.DmFile = null; } }
public static OperationResult <DmSystem> GetDmSystem(string dmPath = "dm.dll") { if (!File.Exists(dmPath)) { return(new OperationResult <DmSystem>(OperationResultType.Error, $"大漠插件文件“{dmPath}”不存在")); } DmPlugin dm = new DmPlugin(dmPath); Version ver = new Version(dm.Ver()); if (ver > new Version("3.1233")) { string code = SoftContext.Locator.Settings.DmRegCode; //code = "rhjv5528a9fb08d84534868df99ad3940be57c"; if (code == null) { return(new OperationResult <DmSystem>(OperationResultType.Error, "大漠插件版本大于“3.1233”,请在“菜单-设置”中设置大漠注册码")); } //int ret = dm.Reg(code); int ret = dm.RegEx(code, "1.0", "221.229.162.75|58.218.204.170|221.229.162.171|221.229.162.40|112.84.124.170"); if (ret != 1) { return(new OperationResult <DmSystem>(OperationResultType.Error, $"大漠插件版本大于“3.1233”,执行插件注册失败,失败码:{ret}")); } } DmSystem system = new DmSystem(dm); return(new OperationResult <DmSystem>(OperationResultType.Success, "大漠系统对象获取成功", system)); }
/// <summary> /// 查找指定区域是否存在图片,存在则点击图片,直到图片消失 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="delay"></param> /// <returns></returns> public static bool FindPicAndClickClear(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, int a = 0, int b = 0, int delay = 1000) { int intX, intY; while (true) { _dm.FindPic(x1, y1, x2, y2, picname, "101010", 0.9, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.MoveToClick(intX + a, intY + b); _dm.Delay(delay); _dm.FindPic(x1, y1, x2, y2, picname, "101010", 0.9, 0, out intX, out intY); if (intX < 0 && intY < 0) { return(true); } } else { return(true); } _dm.Delay(50); } }
/// <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> /// <returns></returns> private uint GetMallLB() { DmPlugin dm = Window.Dm; int hwnd = Window.Hwnd; int val = dm.ReadInt(hwnd, "[16D208C]+238", 0); return((uint)val); }
public DmWindow(DmPlugin dm, int hwnd) { _hwnd = hwnd; _dm = dm; _system = new DmSystem(dm); BindType = WindowBindType.None; IsBind = false; }
/// <summary> /// 获取以逗号分隔的字符串句柄的第一个句柄 /// </summary> /// <param name="hwnds"></param> /// <returns>-1为空</returns> public static int GetHwnd(this DmPlugin dm, string hwnds) { if (string.IsNullOrEmpty(hwnds)) { return(-1); } string[] temp = hwnds.Split(','); return(Convert.ToInt32(temp[0])); }
private void winSpy_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (winSpy.IsMouseLeftButtonDown) { DmPlugin dm = SoftContext.DmSystem.Dm; int hwnd = dm.GetMousePointWindow(); SoftContext.Locator.ClickSettings.Window = new DmWindow(dm, hwnd); } }
/// <summary> /// 获取某个区域相同图片个数 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="sim"></param> /// <returns></returns> public static int GetPicCount(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, double sim = 0.8) { string result = _dm.FindPicEx(x1, y1, x2, y2, picname, "202020", sim, 0); if (result == "") { return(0); } return(result.Split('|').Length); }
private Thread GetWorkThread(IEnumerable <TaskBase> tasks) { return(new Thread(() => { foreach (TaskBase task in tasks) { _task = task; _taskEventArg = new TaskEventArg { Context = _task.TaskContext }; try { //窗口绑定 DmPlugin dm = Window.Dm; bool flag; flag = Delegater.WaitTrue(() => Window.BindHalfBackground(), () => dm.Delay(1000), 10); //flag = Delegater.WaitTrue(() => Window.BindNormal(), () => dm.Delay(1000), 10); if (!flag) { throw new Exception("角色绑定失败,请添加杀软信任,右键以管理员身份运行,Win7系统请确保电脑账户为“Administrator”"); } TaskRunState = TaskRunState.Running; OnStateChanged(_taskEventArg); OnStarted(_taskEventArg); OutMessage("任务“{0}”启动成功。".FormatWith(_task.Name)); TaskStart(); TaskStop(); Window.FlashWindow(); } catch (ThreadAbortException) { TaskStop(true); WaitForUnBind(); break; } catch (Exception ex) { TaskStop(); Window.FlashWindow(); Logger.Error("任务执行失败,{0}", ex.FormatMessage()); OutMessage("任务执行失败,{0}".FormatWith(ex.Message)); } Window.Dm.Delay(1000); TaskList.Remove(task); } WaitForUnBind(); _workThread = null; }) { IsBackground = true }); }
/// <summary> /// 获取仓库金钱 /// </summary> /// <returns></returns> private Money GetRepertoryMoney() { DmPlugin dm = Window.Dm; int hwnd = Window.Hwnd; int val = dm.ReadInt(hwnd, "[16D1E50]+70", 0); Money money = new Money(); money.Gold = (uint)val / 10000; money.Silver = (uint)val % 10000 / 100; money.Copper = (uint)val % 10000 % 100; return(money); }
public bool Teleport(Point point) { IRole role = SoftContext.Role; if (role == null) { return(false); } DmPlugin dm = role.Window.Dm; int hwnd = role.Window.Hwnd; if (point == null) { Debug.WriteLine("坐标不能为null"); return(false); } else { if (role.Window.IsAlive) { this.TeleportByHwnd(dm, hwnd, point); //大号瞬移 ObservableCollection <RoleInfo> roleList = new ViewModelLocator().SetXiaohao.GameRoleList; foreach (var roleInfo in roleList) { if (dm.GetWindowState(roleInfo.Hwnd, 0) != 1) //判断窗口是否存在 { continue; } if (roleInfo.IsTogether) { this.TeleportByHwnd(dm, roleInfo.Hwnd, point); } if (roleInfo.IsMove) //如果移动则写内存 { dm.WriteInt(roleInfo.Hwnd, "[1221740]+2320", 0, 131072); dm.Delay(200); dm.WriteInt(roleInfo.Hwnd, "[1221740]+2320", 0, 0); dm.Delay(100); } } return(true); } else { SoftContext.MainWindow.ShowMessageAsync("瞬移失败", "窗口不存在:" + hwnd); 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="mousedelay">鼠标每步延时</param> /// <param name="mousestep">鼠标步长</param> public static void Swipe(this DmPlugin _dm, int x1, int y1, int x2, int y2, int mousedelay = 30, int mousestep = 10) { _dm.EnableRealMouse(1, mousedelay, mousestep); _dm.MoveTo(x1, y1); _dm.Delay(50); _dm.LeftDown(); _dm.Delay(50); _dm.MoveTo(x2, y2); _dm.Delay(50); _dm.LeftUp(); _dm.Delay(50); _dm.EnableRealMouse(0, mousedelay, mousestep); }
/// <summary> /// 找色并点击 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="color"></param> /// <returns></returns> public static bool FindColorAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string color) { int intX, intY; _dm.FindColor(x1, y1, x2, y2, color, 0.9, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.MoveToClick(intX, intY); _dm.Delay(50); return(true); } 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="color"></param> /// <param name="count"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="sim"></param> /// <returns></returns> public static bool FindColorBlockAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string color, int count, int width, int height, double sim = 0.9) { int intX, intY; bool result = _dm.FindColorBlock(x1, y1, x2, y2, color, sim, count, width, height, out intX, out intY); if (intX > 0 && intY > 0) { _dm.MoveToClick(intX, intY); _dm.DebugPrint(intX + " " + intY); _dm.Delay(50); } return(result); }
/// <summary> /// 多点找色并点击 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="firstColor"></param> /// <param name="offsetColor"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="sim"></param> /// <returns></returns> public static bool FindMultiColorAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string firstColor, string offsetColor, int a = 0, int b = 0, double sim = 0.8) { int intX, intY; _dm.FindMultiColor(x1, y1, x2, y2, firstColor, offsetColor, sim, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.MoveToClick(intX + a, intY + b); _dm.Delay(50); return(true); } return(false); }
/// <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); }
/// <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="intX"></param> /// <param name="intY"></param> /// <param name="sim"></param> /// <returns></returns> public static bool FindStrWithFont_St9_(this DmPlugin dm, int x1, int y1, int x2, int y2, string str, string color, out int intX, out int intY, double sim = 1.0) { int ret = dm.FindStrWithFont(x1, y1, x2, y2, str, color, sim, "宋体", 9, 4, out intX, out intY); if (ret == 1) { return(true); } 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="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); } }
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); } }
/// <summary> /// 将以,号分隔的字符串转换成int列表 /// </summary> /// <param name="hwnds"></param> /// <returns></returns> public static List <int> GetHwnds(this DmPlugin dm, string hwnds) { List <int> hList = new List <int>(); if (string.IsNullOrEmpty(hwnds)) { return(hList); } string[] temp = hwnds.Split(','); foreach (string s in temp) { hList.Add(Convert.ToInt32(s)); } return(hList); }
/// <summary> /// 查找指定区域是否存在图片,存在则点击图片,可设置偏移 /// </summary> /// <param name="_dm"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="picname"></param> /// <param name="a"></param> /// <param name="b"></param> /// <param name="sim"></param> /// <returns></returns> public static bool FindPicAndClick(this DmPlugin _dm, int x1, int y1, int x2, int y2, string picname, int a = 0, int b = 0, double sim = 0.8) { int intX, intY; _dm.FindPic(x1, y1, x2, y2, picname, "202020", sim, 0, out intX, out intY); if (intX > 0 && intY > 0) { _dm.DebugPrint("找图[" + picname + "]成功!" + "坐标:" + intX + " " + intY); _dm.MoveToClick(intX + a, intY + b); _dm.Delay(50); return(true); } _dm.DebugPrint("找图[" + picname + "]失败!"); return(false); }
/// <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(""); } }
/// <summary> /// 指定窗口句柄瞬移 /// </summary> /// <param name="dm"></param> /// <param name="hwnd"></param> /// <param name="point"></param> /// <returns></returns> private bool TeleportByHwnd(DmPlugin dm, int hwnd, Point point) { int a = dm.WriteFloat(hwnd, "[1221740]+a5c", point.X); int b = dm.WriteFloat(hwnd, "[1221740]+a64", point.Y); int c = dm.WriteFloat(hwnd, "[1221740]+a60", point.Z); if (a == 1 && b == 1 && c == 1) { return(true); } else { Debug.WriteLine("瞬移失败,写入X:{0},Y:{1},Z:{2},句柄:{3}", a, b, c, hwnd); return(false); } }