多分辨率通用(ai智能识别微信QQ等均可)
需要依赖插件,demo和插件下载地址如下,自取
点击下载
代码预览
function SwipeRnd() {
this.step = 0.08
}
/**
* @author Mr_老冷 QQ1920712147
* @description 仿真滑动
* @param startX {number} 起点x
* @param startY {number} 起点y
* @param endX {number} 终点x
* @param endY {number} 终点y
* @param timeStart {number} 随机延迟1,默认50ms
* @param timeEnd {number} 随机延迟2,默认timeStart+50ms
* @param timeOut {number} 超时,默认2s
* @param step {number} 步进,默认0.08
* @return {boolean}
*/
SwipeRnd.prototype.rndSwipe = function (startX, startY, endX, endY,
timeStart, timeEnd, timeOut, step) {
timeStart = timeStart || 50
timeEnd = timeEnd || timeStart + 50
timeOut = timeOut || 2 * 1000
this.step = step || this.step
return this._gesture(this._rndSwipe(startX, startY, endX, endY), random(timeStart, timeEnd), timeOut)
}
/**
* @author Mr_老冷 QQ1920712147
* @description 二指仿真滑动
* @param startX {number} 起点x
* @param startY {number} 起点y
* @param endX {number} 终点x
* @param endY {number} 终点y
* @param timeStart {number} 随机延迟1,默认50ms
* @param timeEnd {number} 随机延迟2,默认timeStart+50ms
* @param timeOut {number} 超时,默认2s
* @param step {number} 步进,默认0.08
* @return {boolean}
*/
SwipeRnd.prototype.rndSwipeTwo = function (startX, startY,
endX, endY,
timeStart, timeEnd, timeOut, step) {
timeStart = timeStart || 50
timeEnd = timeEnd || timeStart + 50
timeOut = timeOut || 2 * 1000
this.step = step || this.step
return this._gestureTwo(this._rndSwipe(startX, startY, endX, endY), this._rndSwipe(startX, startY, endX, endY),
random(timeStart, timeEnd), timeOut)
}
SwipeRnd.prototype._bezier_curves = function (cp, t) {
let cx = 3.0 * (cp[1].x - cp[0].x),
bx = 3.0 * (cp[2].x - cp[1].x) - cx,
ax = cp[3].x - cp[0].x - cx - bx,
cy = 3.0 * (cp[1].y - cp[0].y),
by = 3.0 * (cp[2].y - cp[1].y) - cy,
ay = cp[3].y - cp[0].y - cy - by,
tSquared = t * t,
tCubed = tSquared * t
return {
"x": (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x,
"y": (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y
}
}
SwipeRnd.prototype._rndSwipe = function (qx, qy, zx, zy) {
let xxyy = [],
xxy = [],
point = [],
dx = [{
"x": random(qx, qx + 50),
"y": random(qy, qy + 50)
}, {
"x": random(qx - 100, qx + 100),
"y": random(qy, qy + 50)
}, {
"x": random(zx - 100, zx + 100),
"y": random(zy, zy + 50),
}, {
"x": zx,
"y": zy
}]
for (let i = 0; i < dx.length; i++) {
point.push(dx[i])
}
for (let i = 0; i < 1; i += this.step) {
xxyy = [~~(this._bezier_curves(point, i).x), ~~(this._bezier_curves(point, i).y)]
xxy.push(xxyy);
}
return xxy
}
SwipeRnd.prototype._gesture = function (swipeList, time, time1) {
let touch1 = [{"action": 0, "x": swipeList[0][0], "y": swipeList[0][1], "pointer": 1, "delay": time}]
for (let i = 1; i < swipeList.length - 1; i++) {
touch1.push({"action": 2, "x": swipeList[i][0], "y": swipeList[i][1], "pointer": 1, "delay": time});
}
touch1.push({
"action": 1,
"x": swipeList[swipeList.length - 1][0],
"y": swipeList[swipeList.length - 1][1],
"pointer": 1,
"delay": time
})
return multiTouch(touch1, null, null, time1);
}
SwipeRnd.prototype._gestureTwo = function (swipeList, time, time1) {
let swipe = swipeList[0],
swipe1 = swipeList[1],
touch1 = [{"action": 0, "x": swipe[0][0], "y": swipe[0][1], "pointer": 1, "delay": time}],
touch2 = [{"action": 0, "x": swipe1[0][0], "y": swipe1[0][1], "pointer": 2, "delay": time}]
for (let i = 1; i < swipe.length - 1; i++) {
touch1.push({"action": 2, "x": swipe[i][0], "y": swipe[i][1], "pointer": 1, "delay": time});
touch2.push({"action": 2, "x": swipe1[i][0], "y": swipe1[i][1], "pointer": 2, "delay": time});
}
touch1.push({
"action": 1,
"x": swipe[swipe.length - 1][0],
"y": swipe[swipe.length - 1][1],
"pointer": 1,
"delay": time
})
touch2.push({
"action": 1,
"x": swipe1[swipe1.length - 1][0],
"y": swipe1[swipe1.length - 1][1],
"pointer": 2,
"delay": time
})
return multiTouch(touch1, touch2, null, time1);
}
let rSwipe = new SwipeRnd()
let 屏幕高度 = device.getScreenHeight(), 屏幕宽度 = device.getScreenWidth();
let 刷新位置 = ""
let 滑块区域 = {sx: 0, sy: 屏幕高度 * 0.1, ex: 屏幕宽度, ey: 屏幕高度 * 0.5}
function hk() {
return {
init(滑块区域init) {
if (滑块区域init) {
this.滑块区域 = 滑块区域init
}
},
reload() {
clickPoint(刷新位置.x + random(-5, 5), 刷新位置.y + random(-5, 5))
sleep(5 * 1000)
},
execute() {
//滑块刷新位置识别:
let point = null;
//let 滑块区域 = {sx: 0, sy: 屏幕高度 * 0.1, ex: 屏幕宽度, ey: 屏幕高度 * 0.5}
//let 滑块区域 = {sx: 0, sy: 屏幕高度 * 0.3, ex: 屏幕宽度, ey: 屏幕高度 * 0.85}
let bitImg2 = image.captureScreenBitmap("png", 滑块区域.sx, 滑块区域.sy, 滑块区域.ex, 滑块区域.ey, 100) //截图
let 高斯 = imageHandler.gaussianBlur(bitImg2, 3)
imageHandler.recycle(bitImg2)
if (屏幕宽度 === 720) {
point = imageHandler.findCircles(高斯, 10, 0.99, 21, 25, 100);
} else {
point = imageHandler.findCircles(高斯, 10, 0.99, 25, 35, 100);
}
imageHandler.recycle(高斯)
if (point != null && (point.length == 2 || point.length == 1)) {
if ((point.length == 2 && (point[0].y == point[1].y || (point[0].y - point[1].y > 0 && point[0].y - point[1].y < 5) || (point[0].y - point[1].y < 0 && point[0].y - point[1].y > -5))) || point.length == 1) {
logd("滑块页")
if (point.length == 1) {
刷新位置 = point[0];
} else if (point.length == 2 && point[0].x > point[1].x) {
刷新位置 = point[0];
} else {
刷新位置 = point[1];
}
logd(point[0].y)
刷新位置.y = 滑块区域.sy + 刷新位置.y
let bitImg1 = image.captureScreenBitmap("png", 滑块区域.sx, 滑块区域.sy, 滑块区域.ex, 刷新位置.y - 刷新位置.r - 20, 100) //截图
logd("寻找滑块位置")
let minArea = 0, maxArea = 0;
if (屏幕宽度 != 720) {
minArea = 12000;
maxArea = 31000
} else {
minArea = 6000;
maxArea = 20000
}
let 轮廓检测 = imageHandler.canny(bitImg1, 255, 255);
imageHandler.recycle(bitImg1)
let 闭操作 = imageHandler.close(轮廓检测, 1, 5, 5, -1, -1, 2);
imageHandler.recycle(轮廓检测)
let 反向二值化 = imageHandler.binaryzationBitmap(闭操作, 127, 255, 1);
imageHandler.recycle(闭操作)
let stats = imageHandler.connectedComponentsWithStats(反向二值化, 4);
imageHandler.recycle(反向二值化)
let hkLeft = 0;
let hkY = 0;
for (let i = 0; i < stats.length; i++) {
if (stats[i].rectArea >= minArea && stats[i].rectArea <= maxArea && stats[i].center.x > 屏幕宽度 * 0.3 && stats[i].rect.bottom - stats[i].rect.top < 260) {
hkLeft = stats[i].center.x
hkY = stats[i].center.y + 滑块区域.sy
break;
}
}
if (hkLeft != 0) {
this.swipeHK(hkLeft, hkY)
sleep(15000)
} else {
logd("滑块位置未找到,刷新重来")
clickPoint(刷新位置.x + random(-5, 5), 刷新位置.y + random(-5, 5))
sleep(5 * 1000)
}
}
} else {
logd("不是滑块页")
}
},
swipeHK(x, y) {
logd("拉滑块了:x=" + x + ",y=" + y)
let 绿色滑块 = {};
let startX = 0, startY = 0;
if (屏幕宽度 == 1080) {
if (屏幕高度 == 1920) {
绿色滑块.left = 160;
绿色滑块.right = 240;
绿色滑块.cenX = 210;
startX = random(绿色滑块.left, 绿色滑块.right);
startY = random(y - 50, y + 50)
} else if (屏幕高度 == 2340) {
绿色滑块.left = 150;
绿色滑块.right = 240;
绿色滑块.cenX = 205;
startX = random(绿色滑块.left, 绿色滑块.right);
startY = random(y - 50, y + 50)
}
} else if (屏幕宽度 == 720) {
if (屏幕高度 == 1520) {
绿色滑块.left = 100;
绿色滑块.right = 160;
绿色滑块.cenX = 140;
startX = random(绿色滑块.left, 绿色滑块.right);
startY = random(y - 30, y + 30)
}
}
let sv = random(100, 600) * 0.0001
rSwipe.rndSwipe(startX, startY, x + (startX - 绿色滑块.cenX) - 0 + 25, startY + random(-50, 50), random(30, 80), random(100, 130), random(5000, 7000), sv)
}
}
}