最近一直再写刷视频软件脚本,比如手机视频软件太多,每天都需要手动提现羊毛,太累,使用Autojs来帮助我提现,签到,扯远了,因为做刷视频脚本感觉有点无聊,所以试着做小游戏找图脚本看看。
开发小游戏所收获经验:
这些经验我怎么知道的呢?
/** 截图申请,需要确认同意 */
var requestScreenCaptureThread_screenshot = threads.start(function () {
sleep(2000)
var beginBtn;
if (beginBtn = classNameContains("Button").textContains("允许").findOne(2000)) {
beginBtn.click();
}
});
/* 请求截图结果 */
if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
}
var 小兔 = "/sdcard/Pictures/Screenshots/s12.jpg";
var 打开红包 = "/sdcard/Pictures/Screenshots/s14.jpg";
var 开心收下 = "/sdcard/Pictures/Screenshots/s15.jpg";
var 收获 = "/sdcard/Pictures/Screenshots/s16.jpg";
var 播种 = "/sdcard/Pictures/Screenshots/s17.jpg";
var 关闭 = "/sdcard/Pictures/Screenshots/s18.jpg";
var 找多个红包 = "/sdcard/Pictures/Screenshots/s35.jpg";
var 找多个红包1 = "/sdcard/Pictures/Screenshots/s20.jpg";
var 除虫 = "/sdcard/Pictures/Screenshots/s21.jpg";
// var 种植 = "/sdcard/Pictures/Screenshots/s22.jpg";
// var 炼丹= "/sdcard/Pictures/Screenshots/s24.jpg";
var 免费制作= "/sdcard/Pictures/Screenshots/s25.jpg";
var 接单= "/sdcard/Pictures/Screenshots/s27.jpg";
var 立即接单= "/sdcard/Pictures/Screenshots/s28.jpg";
var 紫女红包= "/sdcard/Pictures/Screenshots/s29.jpg";
// var 大号红包= "/sdcard/Pictures/Screenshots/s30.jpg";
// var 播种 = "/sdcard/Pictures/Screenshots/s31.jpg";
var 种植 = "/sdcard/Pictures/Screenshots/s34.jpg";
var 大号红包 = "/sdcard/Pictures/Screenshots/s33.jpg";
var 炼丹 = "/sdcard/Pictures/Screenshots/s36.jpg";
/** 主线程 ,因为是自己刚刚写好的,没有完全的封装好代码,希望谅解*/
while (true) {
findMaps1(收获)
sleep(3000,4000)
findMaps(种植)
sleep(3000,4000)
findMap(炼丹)
sleep(3000,4000)
findMap(免费制作)
sleep(3000,4000)
findMap(除虫)
sleep(3000,4000)
findMaps(找多个红包)
sleep(3000,4000)
findMap(打开红包)
sleep(3000,4000)
findMap(关闭)
sleep(3000,4000)
findMap(开心收下)
sleep(3000,4000)
findMap(接单)
sleep(3000,4000)
findMap(立即接单)
sleep(3000,4000)
findMap(大号红包)
sleep(3000,4000)
findMap(种植)
sleep(3000,4000)
findMap(找多个红包1)
sleep(3000,4000)
}
/**
* 单图点击
* @param {*} name
* @returns
*/
function findMap (name) {
console.log(name);
let img = captureScreen();
let temp1 = images.read(name);
let p = images.findImage(img, temp1);
if (p) {
click(p.x, p.y)
temp1.recycle();
return true;
}
temp1.recycle();
return false;
}
/**
* 多图点击
* @param {*} name
* @returns
*/
function findMaps (name) {
console.log(name);
let img = captureScreen();
let temp1 = images.read(name);
let result = images.matchTemplate(img, temp1, { max: 3 });
if (result.matches.length > 0) {
console.log("11:",result.matches.length);
for (let i = 0; i < result.matches.length; i++) {
let pp = result.matches[i].point
let xx = random(pp.x, pp.x + temp1.getWidth())
let yy = random(pp.y, pp.y + temp1.getWidth())
click(xx, yy)
sleep(2000)
break;
}
temp1.recycle();
return true;
}
temp1.recycle();
return false;
}
function findMaps1 (name) {
console.log(name);
let img = captureScreen();
let temp1 = images.read(name);
let result = images.matchTemplate(img, temp1, { max: 3 });
if (result.matches.length > 0) {
console.log("11:",result.matches.length);
for (let i = 0; i < result.matches.length; i++) {
let pp = result.matches[i].point
let xx = random(pp.x, pp.x + temp1.getWidth())
let yy = random(pp.y, pp.y + temp1.getWidth())
click(xx, yy)
sleep(2000)
}
temp1.recycle();
return true;
}
temp1.recycle();
return false;
}
可能写得不好,希望大佬谅解,如果写得不好或者需要改进的地方,欢迎大佬们指出,毕竟刚自学不久,谢谢