add dialogs, fix code completion

This commit is contained in:
hyb1996
2017-05-08 15:22:01 +08:00
parent 472bd46b87
commit 0349c113ca
40 changed files with 958 additions and 158 deletions

View File

@@ -1 +1,82 @@
__importClass__(com.stardust.scriptdroid.autojs.Shell);
__importClass__(com.stardust.scriptdroid.autojs.api.Shell);
var dialogs = {};
dialogs.rawInput = function(title, prefill){
prefill = prefill || "";
return __runtime__.dialogs.rawInput(title, prefill);
};
dialogs.input = function(title, prefill){
return eval(rawInput(title, prefill));
}
dialogs.prompt = dialogs.rawInput;
dialogs.alert = function(title, prefill){
prefill = prefill || "";
return __runtime__.dialogs.alert(title, prefill);
}
dialogs.confirm = function(title, prefill){
prefill = prefill || "";
return __runtime__.dialogs.confirm(title, prefill);
}
dialogs.select = function(title, items){
return __runtime__.dialogs.select(title, [].slice.call(arguments, 1));
}
dialogs.singleChoice = function(title, index, items){
return __runtime__.dialogs.singleChoice(title, index, [].slice.call(arguments, 2));
}
dialogs.multiChoice = function(title, index, items){
var javaArray = __runtime__.dialogs.multiChoice(title, index, [].slice.call(arguments, 2));
var jsArray = {};
for each(i in javaArray){
jsArray.push(i);
}
return jsArray;
}
var rawInput = function(title, prefill){
return dialogs.rawInput(title, prefill);
}
var input = function(title, prefill){
return dialogs.input(title, prefill);
}
var alert = function(title, prefill){
dialogs.alert(title, prefill);
}
var confirm = function(title, prefill){
return dialogs.confirm(title, prefill);
}
var prompt = function(title, prefill){
return dialogs.prompt(title, prefill);
}
/*
dialogs.rawInput = function(title, prefill){
prefill = prefill || "";
return __runtime__.dialogs.rawInput(title, prefill);
}
dialogs.input = function(title, prefill){
return eval(rawInput(title, prefill));
}
dialogs.alert = function(title, content){
__runtime__.dialogs.alert(title, content);
}
dialogs.select = function(title, content){
__runtime__.dialogs.alert(title, content);
}
*/

View File

@@ -0,0 +1,62 @@
[ "toast",
"app",
"launchPackage",
"launch",
"launchApp",
"getPackageName",
"openAppSetting",
"sleep",
"isStopped",
"notStopped",
"stop",
"console",
"log",
"print",
"err",
"openConsole",
"clearConsole",
"shell",
"currentPackage",
"currentActivity",
"back",
"home",
"powerDialog",
"notifications",
"quickSettings",
"recents",
"splitScreen",
"click",
"longClick",
"scrollDown",
"scrollUp",
"input",
"setClip",
"SetScreenMetrics",
"Tap",
"Swipe",
"Screencap",
"KeyCode",
"Home",
"Back",
"Power",
"Up",
"Down",
"Left",
"Right",
"OK",
"VolumeUp",
"VolumeDown",
"Menu",
"Camera",
"Text",
"selector",
"open",
"newInjectableWebClient",
"newInjectableWebView",
"dialogs",
"rawInput",
"input",
"alert",
"confirm",
"prompt"
]

View File

@@ -0,0 +1,31 @@
var i = dialogs.select("请选择工具", "获取应用包名", "打开应用详情页", "卸载应用");
if(i == -1){
alert("没有选择任何工具!");
}
switch(i){
case 0:
//获取应用包名
appName = rawInput("请输入应用名称", "QQ");
packageName = getPackageName(appName);
toast(packageName);
setClip(packageName);
toast("已复制到剪贴板");
break;
case 1:
//打开应用详情页
appName = rawInput("请输入应用名称", "微信");
openAppSetting(getPackageName(appName));
break;
case 2:
//卸载应用
appName = rawInput("请输入应用名称");
packageName = getPackageName(appName);
if(packageName == ""){
toast("应用不存在");
}else if(confirm("确定卸载应用" + packageName + "吗?")){
app.uninstall(packageName);
}
break;
}

View File

@@ -0,0 +1,2 @@
var appName = rawInput("请输入应用名称");
launchApp(appName);

View File

@@ -0,0 +1,22 @@
var num1 = input("请输入第一个数字");
var op = dialogs.singleChoice("请选择运算", 0, "加", "减", "乘", "除", "幂");
var num2 = input("请输入第二个数字");
var result = 0;
switch(op){
case 0:
result = num1 + num2;
break;
case 1:
result = num1 - num2;
break;
case 2:
result = num1 * num2;
break;
case 3:
result = num1 / num2;
break;
case 4:
result = Math.pow(num1, num2);
break;
}
alert("运算结果", result);

View File

@@ -0,0 +1,20 @@
SetScreenMetrics(1080, 1920);
launchApp("QQ");
//点击动态图标
Tap(891, 1851);
//点击好友动态
Tap(192, 453);
//点击头像
Tap(155, 638);
//点击留言
Tap(747, 775);
while(true){
//点击箭头图标
Tap(1029, 433);
//点击删除
Tap(530, 820);
//点击确定
Tap(331, 1122);
}