# ScriptLib **Repository Path**: d8feel_project/ScriptLib ## Basic Information - **Project Name**: ScriptLib - **Description**: No description available - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 27 - **Created**: 2021-02-26 - **Last Updated**: 2022-05-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ScriptLib **适用于 16+:9 比例分辨率的手游脚本多分辨率适配插件 for AutoJs** 建议在720x1280分辨率配合图色助手取色 图色助手: https://gitee.com/yiszza/ScriptGraphicHelper/releases 不保证适用于所有游戏, 使用前请测试 取点时先观察控件的布局, 可能是居中, 或者是靠左或者是靠右, 然后进行取色 **多分辨率适配原理简单解析:** 明日方舟720x1280与720x1560分辨率下的对比 ![截图](screenshot/screen_1.png) ``` const normal = -1; //定义常量 const left = 0; const center = 1; const right = 2; if (!requestScreenCapture(true)) { alert("请求截图权限失败"); exit(); } runtime.unloadDex(".//scriptlib.dex") runtime.loadDex(".//scriptlib.dex") importClass(com.scriptlib.AnchorGraphicHelper); print("版本号: " + AnchorGraphicHelper.Version()); //静态方法 /** * 构造函数 * * @param obj: aj_runtime * @param devWidth: 开发分辨率_宽 * @param devHeight: 开发分辨率_高 * @param left: 运行设备布局 startX * @param top: 运行设备布局 startY * @param right 运行设备布局 endX * @param bottom: 运行设备布局 endY */ //public AnchorGraphicHelper(Object obj, int devWidth, int devHeight, int left, int top, int right, int bottom) var helper = new AnchorGraphicHelper(runtime, 1280, 720, 0, 0, 2559, 1079); print("获取截图数据到数组: " + helper.KeepScreen(true)); print("获取x,y in left: " + helper.GetPoint(103, 71, left)); print("获取x,y in center: " + helper.GetPoint(103, 71, center)); print("获取x,y in right: " + helper.GetPoint(103, 71, right)); print(helper.GetPixel(100, 100, left));//获取指定像素数据(int数组) print(helper.GetPixel(100, 100, center));//获取指定像素数据(int数组) print(helper.GetPixel(100, 100, right));//获取指定像素数据(int数组) print("获取指定像素数据(hex字符串): " + helper.GetPixelStr(100, 100, left)); print("获取指定像素数据(hex字符串): " + helper.GetPixelStr(100, 100, center)); print("获取指定像素数据(hex字符串): " + helper.GetPixelStr(100, 100, right)); //测试界面: 1080*2560分辨率 放开那三国3(雷电渠道) 公告界面, 见附件 var description = [1280, 720, //图色助手 锚点多点找色格式 or 锚点多点比色格式 [[center, 103, 71, 0xb3833b], [center, 123, 370, 0x994233], [center, 120, 429, 0x712c21], [center, 575, 80, 0xe4ccb3], [center, 688, 81, 0xe2cab1], [center, 1156, 114, 0xffffff], [center, 1175, 112, 0x80280c], [center, 1145, 69, 0xbd8e41], [center, 1151, 414, 0x80342a], [center, 869, 81, 0x722c0c], [center, 774, 71, 0xae5f41], [right, 1244, 151, 0x1d110c], [right, 1226, 163, 0x42361f], [right, 1221, 146, 0x4e4a36], [right, 1224, 63, 0x1f0e09], [right, 1228, 52, 0x4e4c39], [right, 1242, 57, 0x1d0f09]] ]; //在色组定义时提前转换好再调用找色比色 /** * 转换多点比色格式 */ //public int[][] GetCmpColorArray(int devWidth, int devHeight, int[][] description) var cmpColorArray = helper.GetCmpColorArray(description[0], description[1], description[2]); /** * 转换多点找色格式 */ //public int[][] GetFindColorArray(int devWidth, int devHeight, int[][] description) var findColorArray = helper.GetFindColorArray(description[0], description[1], description[2]); /** * 多点找色 * * @param startX: 查找区域的左上X坐标 * @param startY: 查找区域的左上Y坐标 * @param endX: 查找区域的右下Y坐标 * @param endY: 查找区域的右下Y坐标 * @param description: 色组描述 * @param sim: 相似度 * @param offset: 偏移查找 */ //public Point FindMultiColor(int startX, int startY, int endX, int endY, int[][] description, int sim, int offset) print("多点找色: " + helper.FindMultiColor(0, 0, 2559, 1079, findColorArray, 95, 0)); //boolean CompareColorEx(int[][] compareColors, int sim, int offset) print("多点比色: " + helper.CompareColorEx(cmpColorArray, 95, 0)); /** * 伪找图,取图内所有九宫格色差小于12的点,用于多分辨率适配 * * @param devWidth: 开发分辨率_宽 * @param devHeight: 开发分辨率_宽 * @param path: 路径 * @param sim: 相似度 * @param offset: 偏移查找 */ //public Point FindImage(int startX, int startY, int endX, int endY, int devWidth, int devHeight, String path, int sim, int offset) /** * 找图 * * @param path: 路径 * @param sim: 相似度 */ //public Point FindImage(int startX, int startY, int endX, int endY, String path, int sim) print("伪找图: " + helper.FindImage(0, 0, 2559, 1079, 1280, 720, "./test_720p.png", 95, 0)); print("找图720p: " + helper.FindImage(0, 0, 2559, 1079, "./test_720p.png", 95)); print("找图1080p: " + helper.FindImage(0, 0, 2559, 1079, "./test_1080p.png", 95)); /** * 多点找色_返回所有符合的坐标 */ //public List FindMultiColorEx(int startX, int startY, int endX, int endY, int[][] description, int sim, int offset) print(helper.FindMultiColorEx(0, 0, 2559, 1079, findColorArray, 95, 0)); /** * 条件循环多点找色 * * @param description: 色组描述 * @param sim: 相似度 * @param offset: 偏移查找 * @param timeout: 超时时间 * @param timelag: 间隔时间 * @param sign: 跳出条件,0为找色成功时返回,1为找色失败时返回 */ //public Point FindMultiColorLoop(int startX, int startY, int endX, int endY, int[][] description, int sim, int offset, long timeout, long timelag, int sign) /** * 条件循环多点比色 * * @param description: 色组描述 * @param sim: 相似度 * @param offset: 偏移查找 * @param timeout: 超时时间 * @param timelag: 间隔时间 * @param sign: 跳出条件,0为比色成功时返回,1为比色失败时返回 */ //public boolean CompareColorExLoop(int[][] description, int sim, int offset, long timeout, long timelag, int sign) ```