random click and gesture for android 7.0+!!!
This commit is contained in:
@@ -13,17 +13,60 @@ module.exports = function(__runtime__, scope){
|
||||
}
|
||||
|
||||
automator.click = function(){
|
||||
if(arguments.length >= 2 && typeof(arguments[0]) == 'number' && typeof(arguments[1]) == 'number'){
|
||||
return __runtime__.automator.click(arguments[0], arguments[1]);
|
||||
}
|
||||
return performAction(function(target){
|
||||
return __runtime__.automator.click(target);
|
||||
}, arguments);
|
||||
}
|
||||
|
||||
automator.longClick = function(a, b, c, d){
|
||||
if(arguments.length == 2 && typeof(arguments[0]) == 'number' && typeof(arguments[1]) == 'number'){
|
||||
return __runtime__.automator.longClick(arguments[0], arguments[1]);
|
||||
}
|
||||
return performAction(function(target){
|
||||
return __runtime__.automator.longClick(target);
|
||||
}, arguments);
|
||||
}
|
||||
|
||||
automator.press = __runtime__.automator.press.bind(__runtime__.automator);
|
||||
automator.gesture = __runtime__.automator.gesture.bind(__runtime__.automator, 0);
|
||||
automator.gestureAsync = __runtime__.automator.gestureAsync.bind(__runtime__.automator, 0);
|
||||
automator.swipe = __runtime__.automator.swipe.bind(__runtime__.automator);
|
||||
automator.gestures = function(){
|
||||
return __runtime__.automator.gestures(toStrokes(arguments));
|
||||
}
|
||||
|
||||
automator.gesturesAsync = function(){
|
||||
__runtime__.automator.gesturesAsync(toStrokes(arguments));
|
||||
}
|
||||
|
||||
function toStrokes(args){
|
||||
var screenMetrics = __runtime__.getScreenMetrics();
|
||||
var len = args.length;
|
||||
var strokes = [];
|
||||
for(var i = 0; i < len; i++){
|
||||
var gesture = args[i];
|
||||
var pointsIndex = 1;
|
||||
if(typeof(gesture[1]) == 'number'){
|
||||
var start = gesture[0];
|
||||
var delay = gesture[1];
|
||||
pointsIndex = 2;
|
||||
}else{
|
||||
var start = 0;
|
||||
var delay = gesture[0];
|
||||
}
|
||||
var gestureLen = gesture.length;
|
||||
var path = new android.graphics.Path();
|
||||
path.moveTo(screenMetrics.scaleX(gesture[pointsIndex][0]), screenMetrics.scaleY(gesture[pointsIndex][1]));
|
||||
for(var j = pointsIndex + 1; j < gestureLen; j++){
|
||||
path.lineTo(screenMetrics.scaleX(gesture[j][0]), screenMetrics.scaleY(gesture[j][1]));
|
||||
}
|
||||
strokes.push(new android.accessibilityservice.GestureDescription.StrokeDescription(path, start, delay));
|
||||
}
|
||||
return strokes;
|
||||
}
|
||||
|
||||
automator.scrollDown = function(a, b, c, d){
|
||||
if(arguments.length == 0)
|
||||
@@ -54,7 +97,7 @@ module.exports = function(__runtime__, scope){
|
||||
}
|
||||
|
||||
scope.__asGlobal__(__runtime__.automator, ['back', 'home', 'powerDialog', 'notifications', 'quickSettings', 'recents', 'splitScreen']);
|
||||
scope.__asGlobal__(automator, ['click', 'longClick', 'scrollDown', 'scrollUp', 'input']);
|
||||
scope.__asGlobal__(automator, ['click', 'longClick', 'press', 'swipe', 'gesture', 'gestures', 'gestureAsync', 'gesturesAsync', 'scrollDown', 'scrollUp', 'input']);
|
||||
|
||||
return automator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user