/*
软件作者:https://xuhss.com/oxox/pro
*/
/**
*作者QQ: 1811588980
*完成时间: 2019年4月18日 下午9:42:35
*备注: 使用方法
**本脚本使用方式。
* 使用悬浮窗展示的方式对图像选中区域进行找图代码生成。
*截图 重新截图
*选图 从文件夹中选择图片
*区域 将绿色框以选中的区域作为此时找图区域
*加入 对绿色宽选中的区域进行剪切。作为找图时的小图。并以上一步选中的区域作为找图区域。并以此时区域的中心作为点击坐标。
*代码 直接生成找图点击代码。并复制到粘贴板。请自行新建一个脚本粘贴代码(建议格式化代码,方便查看)即可运行。
*关闭 停止使用本功能脚本。
*移动 移动悬浮窗。点击可以最小化 长按也可关闭此脚本。
**/
toastLog("Are you ready?");
if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
};
threads.start(function() {
//console.show();
});
var IMG = captureScreen();
var MainImg = images.copy(IMG);
var window = floaty.rawWindow(
<vertical id="vertical" bg="#aaaaaa" w="{{Math.floor(device.width*0.9)}}px" h="{{Math.floor(device.width*0.9)}}px" gravity="center">
<canvas id="canvas" margin="5dp" layout_weight="1"/>
<HorizontalScrollView w="*">
<horizontal id="horizontal" w="*" gravity="center">
<button id="butJ" layout_weight="1" text="截图"/>
<button id="openImage" layout_weight="1" text="选图"/>
<button id="getRegion" layout_weight="1" text="区域"/>
<button id="addImg" layout_weight="1" text="加入"/>
<button id="setClip" layout_weight="1" text="代码"/>
<button id="butG" layout_weight="1" text="关闭"/>
</horizontal>
</HorizontalScrollView>
<button id="butY" w="*" text="移动"/>
</vertical>
);
var window_ = floaty.window(
<button id="but_" w="150px" h="150px" text="▽" alpha="0.7"/>
);
var ad = new 悬浮控制(window, window.butY, 1, window.vertical);
var ad_ = new 悬浮控制(window_, window_.but_);
var F = ad.OutScreen();
var F_ = ad_.OutScreen();
threads.start(function() {
sleep(100);
F_ = ad_.OutScreen();
ad_.windowyidong(F_);
});
ad.setClick(function() {
//window.disableFocus();
threads.start(function() {
F = ad.OutScreen();
ad.windowyidong(F);
ad_.windowyidong([F_[1], ad_.centerXY(ad.centerXY(F[0])[0])[1]]);
ad_.windowyidong(ad_.IntScreen());
ad_.windowyidong(ad_.toScreenEdge(0));
});
});
ad_.setClick(function() {
//window.disableFocus();
threads.start(function() {
F_ = ad_.OutScreen();
ad_.windowyidong(F_);
ad.windowyidong([F[1], ad.centerXY(ad_.centerXY(F_[0])[0])[1]]);
ad.windowyidong(ad.IntScreen());
});
});
window.butJ.click(function() {
threads.start(function() {
var F = ad.OutScreen();
ad.windowyidong(F);
sleep(100);
IMG = captureScreen();
//img.recycle();
MainImg = images.copy(IMG);
ad.windowyidong(F.reverse());
});
});
window.butG.on("click", () => {
exit()
});
ad.setLongClick(exit);
ad_.setLongClick(exit);
threads.start(function() {
sleep(100);
window.setPosition(device.width / 2 - window.getWidth() / 2, device.height / 2 - window.getHeight() / 2);
});
//黑色画笔。
var paint = new Paint;
var paint1 = new Paint;
var paint2 = new Paint;
//paint1.setTextSize(75);
//paint.setTextAlign(Paint.Align.CENTER);
paint.setStrokeWidth(0.675);
paint1.setStrokeWidth(0.675);
paint.setStyle(Paint.Style.STROKE);
paint1.setStyle(Paint.Style.STROKE);
paint2.setStyle(Paint.Style.FILL);
//paint.setARGB(255, 0, 0, 0);
paint.setColor(colors.RED);
paint1.setColor(colors.GREEN);
paint2.setColor(colors.GREEN);
//paint.setTextSize(75);
//android.view.MotionEvent
var findImageDataAry = new Array;
events.on("exit", clipToCode);
/*元素结构。
{
template:"fhfcgh==",//base64
options: {
region: [0, 0],
threshold: 0.8
},
p:{x:0,y:0},
};
*/
/*导出元素结构。
{
template:images.fromBase64("fhfcgh=="),//base64
options: {
region: [0, 0],
threshold: 0.8
},
p:{x:0,y:0},
};
*/
var imageRect = new android.graphics.RectF;
var canvasRect = new android.graphics.RectF;
var canvasMatrix = new android.graphics.Matrix;
var ASX = new XYToMatrix(canvasMatrix);
window.openImage.click(function() {
threads.start(function() {
var F = ad.OutScreen();
ad.windowyidong(F);
sleep(100);
var path = selectFile("/sdcard", "/脚本", function(dir, name) {
return name.endsWith(".jpg") || name.endsWith(".png") || files.isDir(files.join(dir, name));
});
if (path) {
var img = MainImg;
MainImg = 加载图片(path);
if (MainImg) {
imageRect.set(new android.graphics.RectF(0, 0, MainImg.getWidth(), MainImg.getHeight()));
canvasMatrix.setRectToRect(imageRect, canvasRect, android.graphics.Matrix.ScaleToFit.CENTER);
};
if (img) {
img.recycle();
};
};
ad.windowyidong(F.reverse());
});
});
var RE_rect;
window.getRegion.click(function() {
if (MainImg) {
RE_rect = new android.graphics.RectF(imageRect);
toastLog("OK");
};
});
window.addImg.click(function() {
if (MainImg) {
let x1 = imageRect.left < imageRect.right ? imageRect.left : imageRect.right,
y1 = imageRect.top < imageRect.bottom ? imageRect.top : imageRect.bottom,
x2 = imageRect.right >= imageRect.left ? imageRect.right : imageRect.left,
y2 = imageRect.bottom >= imageRect.top ? imageRect.bottom : imageRect.top;
let w = x2 - x1,
h = y2 - y1;
let cx = Math.floor(x1 + w / 2),
cy = Math.floor(y1 + h / 2);
let x_1 = x1,
y_1 = y1,
x_2 = x2,
y_2 = y2;
let w_ = w,
h_ = h;
let c_x = cx,
c_y = cy;
if (RE_rect) {
if (!RE_rect.contains(imageRect)) {
toastLog("错╳╳╳╳╳误");
toastLog("图片大于找图范围");
return;
};
x_1 = RE_rect.left < RE_rect.right ? RE_rect.left : RE_rect.right;
y_1 = RE_rect.top < RE_rect.bottom ? RE_rect.top : RE_rect.bottom;
x_2 = RE_rect.right >= RE_rect.left ? RE_rect.right : RE_rect.left;
y_2 = RE_rect.bottom >= RE_rect.top ? RE_rect.bottom : RE_rect.top;
w_ = x_2 - x_1;
h_ = y_2 - y_1;
c_x = Math.floor(x_1 + w_ / 2);
c_y = Math.floor(y_1 + h_ / 2);
};
let img = images.clip(MainImg, x1, y1, w, h);
/*
let file = new java.io.File(saveDir);
let toName = files.getNameWithoutExtension(imagePath) + "(剪切)" + getTimeString() + "." + files.getExtension(imagePath);
let toPath = files.join(file.getParent(), toName);
let objStr = JSON.stringify({
name: toName,
region: [x1, y1, x2 - x1, y2 - y1],
threshold: 0.8
});
//var toPath = "/sdcard/脚本/" + (new Date().getTime()) + ".png";
images.save(img, toPath, "png", 100);
//img.recycle();
//media.scanFile(toPath);
*/
let base64Img = images.toBase64(img, "png", 100);
findImageDataAry.push(
[虚幻私塾】
- 粉丝: 337
- 资源: 1558
最新资源
- Python基于用户的协同过滤算法和项目的协同过滤算法实现的电影推荐系统源码+报告
- 永磁电机结构介绍和设计分析
- YOLO框架讲解新版PDF
- unity-shader制作绘制网格贪吃蛇
- SIMATIC S7 Distributed Safety V5.4 SP5 更新 2-链接地址.txt
- 常见功率dBm与电压v转换表
- IBM Intelligent Data Fabric数据经纬和数据虚拟化
- 易优CMS+响应式建站模板PHP+Mysql+E000570机械扫雪设备类网站模板.zip
- 互联网安全试题及答案 选择题
- ubuntu server安装PDF
- AI Agent 技术白皮书 2024.pdf
- Javascript基础-Javascript学习笔记(一)PDF
- 2024年第九届全国固态电池研讨会(脱敏)PPT合集(41份).zip
- WebSocket连接负载平衡的实现PDF
- 基于朴素贝叶斯算法解决新闻分类问题项目源码
- 基于朴素贝叶斯的文本数据的分类与分析实验项目源码+数据(高分项目)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈