mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
docs: RootAutomator
This commit is contained in:
parent
9e23d9c245
commit
a72147fcf2
@ -2,9 +2,8 @@
|
||||
|
||||
RootAutomator是一个使用Root权限来模拟触摸的对象,用它可以完成触摸与多点触摸,并且这些动作的执行没有延迟。
|
||||
|
||||
构造RootAutomator需要一个context参数。
|
||||
```
|
||||
var ra = RootAutomator(context);
|
||||
var ra = RootAutomator();
|
||||
```
|
||||
|
||||
### RootAutomator.tap(x, y\[, id\])
|
||||
@ -14,7 +13,7 @@ var ra = RootAutomator(context);
|
||||
|
||||
点击位置(x, y)。其中id是一个整数值,用于区分多点触摸,不同的id表示不同的"手指",例如:
|
||||
```
|
||||
var ra = RootAutomator(context);
|
||||
var ra = RootAutomator();
|
||||
//让"手指1"点击位置(100, 100)
|
||||
ra.tap(100, 100, 1);
|
||||
//让"手指2"点击位置(200, 200);
|
||||
|
||||
@ -326,22 +326,4 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
return mActivityResultMediator;
|
||||
}
|
||||
|
||||
public static void onRecordStop(Context context, String script) {
|
||||
Intent intent = new Intent(context, MainActivity_.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(EXTRA_ACTION, ACTION_ON_RECORD_STOP);
|
||||
IntentExtras.newExtras()
|
||||
.put(ARGUMENT_SCRIPT, script)
|
||||
.putInIntent(intent);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
public static void onRootRecordStop(Context context, String path) {
|
||||
Intent intent = new Intent(context, MainActivity_.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(EXTRA_ACTION, ACTION_ON_ROOT_RECORD_STOP)
|
||||
.putExtra(ARGUMENT_PATH, path);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
module.exports = function(__runtime__, scope){
|
||||
function RootAutomator(){
|
||||
this.__ra__ = Object.create(new com.stardust.autojs.runtime.api.RootAutomator(scope.context));
|
||||
this.__ra__ = Object.create(new com.stardust.autojs.runtime.api.RootAutomator(scope.context));
|
||||
var methods = ["sendEvent", "touch", "setScreenMetrics", "touchX", "touchY", "sendSync", "sendMtSync", "tap",
|
||||
"swipe", "press", "longPress", "touchDown", "touchUp", "touchMove", "getDefaultId", "setDefaultId", "exit"];
|
||||
for(var i = 0; i < methods.length; i++){
|
||||
var method = methods[i];
|
||||
this[method] = this.__ra__[method].bind(this.__ra__);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
var p = RootAutomator.prototype;
|
||||
return RootAutomator;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user