add console.rawInput, app.intent
This commit is contained in:
@@ -17,19 +17,13 @@ var toast = function(text){
|
||||
__runtime__.toast(text);
|
||||
}
|
||||
|
||||
var app = __runtime__.app;
|
||||
var app = require("app")(__runtime__);
|
||||
|
||||
var launchPackage = function(package){
|
||||
app.launchPackage(package);
|
||||
}
|
||||
|
||||
var launch = function(a, b){
|
||||
if(arguments.length == 2){
|
||||
app.launch(a, b);
|
||||
}else{
|
||||
app.launchPackage(a);
|
||||
}
|
||||
}
|
||||
var launch = app.launch.bind(app);
|
||||
|
||||
var launchApp = function(appName){
|
||||
app.launchApp(appName);
|
||||
@@ -44,6 +38,7 @@ var openAppSetting = function(packageName){
|
||||
}
|
||||
|
||||
|
||||
|
||||
var sleep = function(millis){
|
||||
__runtime__.sleep(millis);
|
||||
}
|
||||
@@ -81,9 +76,6 @@ var clearConsole = function(){
|
||||
}
|
||||
|
||||
var shell = function(cmd, root){
|
||||
if(arguments.length == 1){
|
||||
return new com.stardust.scriptdroid.tool.Shell(context, arguments[0] ? 1 : 0);
|
||||
}
|
||||
root = root ? 1 : 0;
|
||||
return __runtime__.shell(cmd, root);
|
||||
}
|
||||
@@ -96,6 +88,8 @@ var currentActivity = function(){
|
||||
return __runtime__.info.getLatestActivity();
|
||||
}
|
||||
|
||||
|
||||
|
||||
var __this__ = this;
|
||||
|
||||
var back = function(){
|
||||
@@ -126,7 +120,6 @@ var splitScreen = function(){
|
||||
return __runtime__.automator.splitScreen();
|
||||
}
|
||||
|
||||
|
||||
function performAction(action, args){
|
||||
if(args.length == 4){
|
||||
return action(__runtime__.automator.bounds(args[0], args[1], args[2], args[3]));
|
||||
|
||||
43
autojs/src/main/assets/modules/app.js
Normal file
43
autojs/src/main/assets/modules/app.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
module.exports = function(__runtime__){
|
||||
var app = new Object(__runtime__.app);
|
||||
|
||||
app.intent = function(i) {
|
||||
var intent = new android.content.Intent();
|
||||
if (i.className && i.packageName) {
|
||||
intent.setClassName(i.packageName, i.className);
|
||||
}
|
||||
if (i.extras) {
|
||||
for (var key in i.extras) {
|
||||
intent.putExtra(key, i.extras[key].toString());
|
||||
}
|
||||
}
|
||||
if (i.category) {
|
||||
for (var key in i.category) {
|
||||
intent.addCategory(key, i.category[key]);
|
||||
}
|
||||
}
|
||||
if (i.action) {
|
||||
intent.setAction(i.action);
|
||||
}
|
||||
if (i.type) {
|
||||
intent.setType(i.type);
|
||||
}
|
||||
if (i.data) {
|
||||
intent.setData(android.net.Uri.parse(i.data));
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
app.startActivity = function(i){
|
||||
context.startActivity(app.intent(i));
|
||||
}
|
||||
|
||||
app.sendBroadcast = function(i){
|
||||
context.sendBroadcast(app.intent(i));
|
||||
}
|
||||
|
||||
app.launch = app.launchPackage;
|
||||
|
||||
return app;
|
||||
}
|
||||
Reference in New Issue
Block a user