适用于 16+:9 比例分辨率的手游脚本多分辨率适配插件 for AutoJs
建议在720x1280p分辨率配合图色助手取色
图色助手: https://gitee.com/yiszza/ScriptGraphicHelper/releases
不保证适用于所有游戏, 使用前请测试
取点时先观察控件的布局, 可能是居中, 或者是靠左或者是靠右, 然后进行取色
明日方舟720x1280与720x1560分辨率下的对比
const none = -1; //定义常量
const left = 0;
const center = 1;
const right = 2;
//申请截图
if (!requestScreenCapture(true)) {
alert("请求截图权限失败");
exit();
}
//加载dex
runtime.unloadDex(".//scriptlib.dex")
runtime.loadDex(".//scriptlib.dex")
//导入类
importClass(com.scriptlib.AnchorGraphicHelper);
返回值 | 方法 | 描述 |
---|---|---|
static AnchorGraphicHelper | Create | 创建实例 |
static String | Version | 获取版本号 |
void | ReInitialize | 重新初始化环境 |
boolean | KeepScreen | 获取截图数据到数组 |
void | GetRedList | 获取所有r值对应的坐标 |
byte[] | GetScreenData | 获取图像数据 |
Bitmap | GetBitmap | 获取bitmap |
int[] | GetPixel | 获取指定像素数据<byte[]> |
String | GetPixelStr | 获取指定像素数据<String > |
int | GetPixelHex | 获取指定像素数据<int > |
int[] | GetRange | 获取与运行分辨率相关的范围 |
Point | GetPoint | 获取与运行分辨率相关的坐标 |
int[][] |
GetFindColorArray | 获取与运行分辨率相关的找色色组 |
Point | FindMultiColor | 多点找色 |
List<Point> |
FindMultiColorEx | 多点找色返回所有坐标 |
Point | FindMultiColorLoop | 条件循环多点找色 |
int[][] |
GetCmpColorArray | 获取与运行分辨率相关的比色色组 |
boolean | CompareColor | 单点比色 |
boolean | CompareColorEx | 多点比色 |
boolean | CompareColorExLoop | 条件循环多点比色 |
static AnchorGraphicHelper Create(Object obj, int devWidth, int devHeight, int left, int top, int right, int bottom);
静态构造函数, 当初始化失败时返回null
参数 | 描述 |
---|---|
obj | autojs.runtime |
devWidth | 开发分辨率 宽 |
devHeight | 开发分辨率 高 |
left | 运行分辨率布局 startX |
top | 运行分辨率布局 startY |
right | 运行分辨率布局 endX |
bottom | 运行分辨率布局 endY |
例子:
let helper = AnchorGraphicHelper.Create(runtime, 1280, 720, 0, 0, width - 1, height - 1);
if(helper == null){
alert("插件初始化失败!");
return;
}
static String Version();
例子:
print(AnchorGraphicHelper.Version());
void ReInitialize();
使用KeepScreen(bitmap, bool)方法后, 如果需要调用KeepScreen(bool), 请先调用ReInitialize()方法
例子:
helper.ReInitialize();
boolean KeepScreen(boolean sign);
从屏幕获取截图数据到数组
参数 | 描述 |
---|---|
sign | 是否需要调用多点找色 |
boolean KeepScreen(Bitmap bitmap, boolean sign);
从图片获取数据到数组, 只推荐用于测试
参数 | 描述 |
---|---|
bitmap | android.Graphic.Bitmap对象, 这个对象需要你使用后自行释放 |
例子:
helper.KeepScreen(true);
let fis = new FileInputStream(file_name);
let bitmap = BitmapFactory.decodeStream(fis);
helper.KeepScreen(bitmap, true);
fis.close();
bitmap.recycle();
void GetRedList();
例子:
helper.GetRedList();
byte[] GetScreenData();
返回当前图像数据
例子:
let bytes = helper.GetScreenData();
Bitmap GetBitmap();
Bitmap GetBitmap(int sx, int sy, int ex, int ey);
参数 | 描述 |
---|---|
sx | 当前分辨率的startX |
sy | 当前分辨率的startY |
ex | 当前分辨率的endX |
ey | 当前分辨率的endY |
返回当前Bitmap, 这个对象需要你使用后自行释放
例子:
let bitmap1 = helper.GetBitmap();
let bitmap2 = helper.GetBitmap(0,0,200,200);
//some codes
bitmap1.recycle();
bitmap2.recycle();
int[] GetPixel(int x, int y, int mode);
参数 | 描述 |
---|---|
x | 开发分辨率的x |
y | 开发分辨率的y |
mode | 坐标对齐方式 |
例子:
let pixel = helper.GetPixel(50,50,left);
String
>String GetPixelStr(int x, int y, int mode);
例子:
let pixel = helper.GetPixelStr(50,50,center);
int
>int GetPixelHex(int x, int y, int mode);
例子:
let pixel = helper.GetPixelHex(50,50,right);
int[] GetRange(int sx, int sy, int ex, int ey, int mode)
参数 | 描述 |
---|---|
sx | 开发分辨率的startX |
sy | 开发分辨率的startY |
ex | 开发分辨率的endX |
ey | 开发分辨率的endY |
mode | 坐标对齐方式 |
int[] GetRange(int sx, int sy, int smode, int ex, int ey, int emode);
参数 | 描述 |
---|---|
smode | sx和sy的坐标对齐方式 |
emode | sx和sy的坐标对齐方式 |
例子:
let range1 = helper.GetRange(100, 100, 500, 500, center);
let range2 = helper.GetRange(100, 100, left, 500, 500, right);
Point GetPoint(int x, int y, int mode);
参数 | 描述 |
---|---|
x | 开发分辨率的x |
y | 开发分辨率的y |
mode | 坐标对齐方式 |
例子:
let point = helper.GetRange(100, 100, center);
int[][]
GetFindColorArray(String description);
参数 | 描述 |
---|---|
description | 锚点色组字符串 |
例子:
let desc = "1080,1920,left|113|301|0x37474f,center|697|320|0x37474f,center|565|617|0xfafafa,left|238|384|0x37474f";
let findColorArray = helper.GetFindColorArray(desc);
int[][]
GetFindColorArray(int devWidth, int devHeight, int[][]
description);
参数 | 描述 |
---|---|
devWidth | 开发分辨率 宽 |
devHeight | 开发分辨率 高 |
description | 锚点色组 |
例子:
let desc = [1280, 720,
[
[center, 106, 72, 0xb1833a],
[center, 161, 68, 0xc49143],
[center, 568, 92, 0xd6b89c],
[center, 697, 84, 0xdcc4aa],
[center, 1033, 643, 0x41343c]
]
];
let findColorArray = helper.GetFindColorArray(desc[0],desc[1],desc[2]);
Point FindMultiColor(int[] range, int[][]
description, int sim, boolean offset);
Point FindMultiColor(int sx, int sy, int ex, int ey, int[][]
description, int sim, boolean offset);
参数 | 描述 |
---|---|
sx | 运行分辨率的startX |
sy | 运行分辨率的startY |
ex | 运行分辨率的endX |
ey | 运行分辨率的endY |
description | 色组描述 |
sim | 相似度 |
offset | 是否偏移查找 |
例子:
let result = helper.FindMultiColor(0, 0, 1000, 500, findColorArray, 95, 0);
List<Point>
FindMultiColorEx(int[] range, int[][]
description, int sim);
List<Point>
FindMultiColorEx(int[] range, int[][]
description, int sim, int filterNum);
List<Point>
FindMultiColorEx(int sx, int sy, int ex, int ey, int[][]
description, int sim);
List<Point>
FindMultiColorEx(int sx, int sy, int ex, int ey, int[][]
description, int sim, int filterNum);
List<Point>
FindMultiColorEx(int[] range, int[][]
description, int sim, int filterNum, boolean offset);
List<Point>
FindMultiColorEx(int sx, int sy, int ex, int ey, int[][]
description, int sim, boolean offset);
List<Point>
FindMultiColorEx(int sx, int sy, int ex, int ey, int[][]
description, int sim, int filterNum, boolean offset);
参数 | 描述 |
---|---|
sx | 运行分辨率的startX |
sy | 运行分辨率的startY |
ex | 运行分辨率的endX |
ey | 运行分辨率的endY |
description | 色组描述 |
sim | 相似度 |
filterNum | 过滤半径, 默认-1, 去除重叠区域 |
filterNum | 是否偏移查找 |
例子:
let result = helper.FindMultiColorEx(0, 0, 1000, 500, findColorArray, 95);
Point FindMultiColorLoop(int[] range, int[][] description, int sim, boolean offset, long timeout, long timelag, int sign);
Point FindMultiColorLoop(int sx, int sy, int ex, int ey, int[][] description, int sim, boolean offset, long timeout, long timelag, int sign);
参数 | 描述 |
---|---|
sx | 运行分辨率的startX |
sy | 运行分辨率的startY |
ex | 运行分辨率的endX |
ey | 运行分辨率的endY |
description | 色组描述 |
sim | 相似度 |
offset | 是否偏移查找 |
timeout | 超时时间 |
timelag | timelag |
sign | 跳出条件,0为找色成功时返回,1为找色失败时返回 |
例子:
let result = helper.FindMultiColorLoop(0, 0, 1000, 500, findColorArray, 95, 0, 60000, 1000, 0);
if(result.x != -1){
print("循环多点找色条件达成");
}
int[][]
GetCmpColorArray(String description);
参数 | 描述 |
---|---|
description | 锚点色组字符串 |
例子:
let desc = "1080,1920,left|113|301|0x37474f,center|697|320|0x37474f,center|565|617|0xfafafa,left|238|384|0x37474f";
let CmpColorArray = helper.GetCmpColorArray(desc);
int[][]
GetCmpColorArray(int devWidth, int devHeight, int[][]
description);
参数 | 描述 |
---|---|
devWidth | 开发分辨率 宽 |
devHeight | 开发分辨率 高 |
description | 锚点色组 |
例子:
let desc = [1280, 720,
[
[center, 106, 72, 0xb1833a],
[center, 161, 68, 0xc49143],
[center, 568, 92, 0xd6b89c],
[center, 697, 84, 0xdcc4aa],
[center, 1033, 643, 0x41343c]
]
];
let CmpColorArray = helper.GetCmpColorArray(desc[0],desc[1],desc[2]);
boolean CompareColor(int[] description, int sim, boolean offset);
参数 | 描述 |
---|---|
description | 色组描述 |
sim | 相似度 |
offset | 是否偏移查找 |
例子:
print(helper.CompareColor([50,50,0xff,0xff,0xff,0,0,0,0], 95, false);
boolean CompareColorEx(int[][]
description, int sim, boolean offset);
参数 | 描述 |
---|---|
description | 色组描述 |
sim | 相似度 |
offset | 是否偏移查找 |
例子:
print(helper.CompareColor(CmpColorArray, 95, false);
boolean CompareColorExLoop(int[][]
description, int sim, boolean offset, long timeout, long timelag, int sign);
参数 | 描述 |
---|---|
description | 色组描述 |
sim | 相似度 |
offset | 是否偏移查找 |
timeout | 超时时间 |
timelag | timelag |
sign | 跳出条件,0为找色成功时返回,1为找色失败时返回 |
例子:
let result = helper.CompareColorExLoop(0, 0, 1000, 500, findColorArray, 95, false, 60000, 1000, 0);
if(result){
print("循环多点比色条件达成");
}
主要应用于部分客户手机录屏工具和脚本录屏冲突的问题
返回值 | 方法 | 描述 |
---|---|---|
RecordHelper | .ctor | 构造函数 |
boolean | Start | 开始录屏 |
void | Stop | 结束录屏 |
RecordHelper(Object obj, int width, int height, int dpi, String path);
参数 | 描述 |
---|---|
obj | autojs runtime |
width | 宽 |
height | 高 |
dpi | dpi |
path | 录屏保存路径 |
例子:
importClass(com.scriptlib.RecordHelper);
let recordHelper = new RecordHelper(runtime, 1920, 1080, 480, "/sdcard/record.mp4");
boolean Start();
例子:
threads.start(function () {
recordHelper.Start();
});
void Stop();
例子:
recordHelper.Stop();
[center, 158, 203, 0xe027cc]
[center, 158, 203, 0xe027cc, 0x101010]
[center, 158, 203, 0xe027cc, 1] //默认比色成功时返回true, 当添加反转条件时, 比色失败时返回true
[center, 158, 203, 0xe027cc, 0x101010, 1]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。