6.7.0 - Alpha6 - Fine tuning
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
let {versionName, versionCode, versionDate} = autojs;
|
||||
Object.entries({versionName, versionCode, versionDate}).forEach((entry) => {
|
||||
let [key, value] = entry;
|
||||
let { versionName, versionCode, versionDate } = autojs;
|
||||
Object.entries({ versionName, versionCode, versionDate }).forEach((entry) => {
|
||||
let [ key, value ] = entry;
|
||||
console.log(`${key}: ${value}`);
|
||||
});
|
||||
|
||||
@@ -15,4 +15,4 @@ console.log(`Display over other apps: ${autojs.canDisplayOverOtherApps()}`);
|
||||
console.log(`Modify system settings: ${autojs.canModifySystemSettings()}`);
|
||||
console.log(`Write secure settings: ${autojs.canWriteSecureSettings()}`);
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -8,21 +8,21 @@ console.log(`Root access: ${autojs.isRootAvailable()}`);
|
||||
// 1 or true or 'root' (force set root mode)
|
||||
// zh-CN: 1 或 true 或 'root' (强制设置 Root 模式)
|
||||
autojs.setRootMode(true);
|
||||
console.log(`setRootMode(true)`)
|
||||
console.log(`setRootMode(true)`);
|
||||
// true
|
||||
console.log(`Root access: ${autojs.isRootAvailable()}`);
|
||||
|
||||
// 0 or false or 'non-root' (force set non-root mode)
|
||||
// zh-CN: 0 或 false 或 'non-root' (强制设置非 Root 模式)
|
||||
autojs.setRootMode(false);
|
||||
console.log(`setRootMode(false)`)
|
||||
console.log(`setRootMode(false)`);
|
||||
// false
|
||||
console.log(`Root access: ${autojs.isRootAvailable()}`);
|
||||
|
||||
// -1 or 'auto' (auto detect)
|
||||
// zh-CN: -1 或 'auto' (自动检测 Root 模式)
|
||||
autojs.setRootMode('auto');
|
||||
console.log(`setRootMode(auto)`)
|
||||
console.log(`setRootMode(auto)`);
|
||||
// depends on system again
|
||||
// zh-CN: 再次取决于系统检测结果
|
||||
console.log(`Root access: ${autojs.isRootAvailable()}`);
|
||||
@@ -47,4 +47,4 @@ console.launch();
|
||||
// 如需改变软件配置参数 可在 "AutoJs6 > 设置" 中更改
|
||||
// 也可通过 autojs.setRootMode() 的第二项参数直接将修改应用到软件配置参数
|
||||
// 如强制非 Root 模式: autojs.setRootMode('non-root', true);
|
||||
// 也可使用字符串参数: autojs.setRootMode('non-root', 'write_into_pref');
|
||||
// 也可使用字符串参数: autojs.setRootMode('non-root', 'write_into_pref');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//如果遇到SocketTimeout的异常,重新多运行几次脚本即可
|
||||
// 如果遇到 SocketTimeout 的异常, 重新多运行几次脚本即可
|
||||
|
||||
console.show();
|
||||
example1();
|
||||
@@ -6,35 +6,35 @@ example2();
|
||||
example3();
|
||||
example4();
|
||||
|
||||
function example1(){
|
||||
var res = http.postMultipart("http://posttestserver.com/post.php", {
|
||||
"file": open("/sdcard/1.txt")
|
||||
function example1() {
|
||||
var res = http.postMultipart('http://posttestserver.com/post.php', {
|
||||
'file': open('/sdcard/1.txt'),
|
||||
});
|
||||
log("例子1:");
|
||||
log('例子 1:');
|
||||
log(res.body.string());
|
||||
}
|
||||
|
||||
function example2(){
|
||||
var res = http.postMultipart("http://posttestserver.com/post.php", {
|
||||
"file": ["1.txt", "/sdcard/1.txt"]
|
||||
function example2() {
|
||||
var res = http.postMultipart('http://posttestserver.com/post.php', {
|
||||
'file': [ '1.txt', '/sdcard/1.txt' ],
|
||||
});
|
||||
log("例子2:");
|
||||
log('例子 2:');
|
||||
log(res.body.string());
|
||||
}
|
||||
|
||||
function example3(){
|
||||
var res = http.postMultipart("http://posttestserver.com/post.php", {
|
||||
"file": ["1.txt", "text/plain", "/sdcard/1.txt"]
|
||||
function example3() {
|
||||
var res = http.postMultipart('http://posttestserver.com/post.php', {
|
||||
'file': [ '1.txt', 'text/plain', '/sdcard/1.txt' ],
|
||||
});
|
||||
log("例子3:");
|
||||
log('例子 3:');
|
||||
log(res.body.string());
|
||||
}
|
||||
|
||||
function example4(){
|
||||
var res = http.postMultipart("http://posttestserver.com/post.php", {
|
||||
"file": open("/sdcard/1.txt"),
|
||||
"aKey": "aValue"
|
||||
function example4() {
|
||||
var res = http.postMultipart('http://posttestserver.com/post.php', {
|
||||
'file': open('/sdcard/1.txt'),
|
||||
'aKey': 'aValue',
|
||||
});
|
||||
log("例子4:");
|
||||
log('例子 4:');
|
||||
log(res.body.string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ if (res.statusCode !== 200) {
|
||||
let path = './github-mark.png';
|
||||
files.writeBytes(path, res.body.bytes());
|
||||
toast(`下载成功: ${path}`);
|
||||
app.viewFile(path);
|
||||
app.viewFile(path);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
let MAX_LENGTH_TO_PRINT = 3000;
|
||||
|
||||
let url = 'https://www.npmjs.com';
|
||||
let url = 'https://github.com';
|
||||
let res = http.get(url);
|
||||
if (res.statusCode !== 200) {
|
||||
toast(`请求失败: ${res.statusMessage}`);
|
||||
toast(`请求失败 [${res.statusCode}]: "${res.statusMessage}"`);
|
||||
exit();
|
||||
}
|
||||
let str = res.body.string();
|
||||
|
||||
@@ -140,10 +140,10 @@ var order = <order id = "123456" timestamp="Mon Mar 10 2003 16:03:25 GMT-0800 (P
|
||||
print("The order id is:" + order.@id);
|
||||
|
||||
// get all the child elements from the order element
|
||||
print("The children of the order are:\n" + order.*);
|
||||
print("The children of the order are:\n" + order.*);
|
||||
|
||||
// get the list of all item descriptions
|
||||
print("The order descriptions are:\n" + order.item.description);
|
||||
print("The order descriptions are:\n" + order.item.description);
|
||||
|
||||
|
||||
// get second item by numeric index
|
||||
@@ -176,7 +176,7 @@ print("All the employee names are:\n" + e..name);
|
||||
print("The employee named Joe is:\n" + e.employee.(name == "Joe"));
|
||||
|
||||
// employees with id's 1 & 2
|
||||
print("Employees with ids 1 & 2:\n" + e.employee.(@id == 1 || @id == 2));
|
||||
print("Employees with ids 1 & 2:\n" + e.employee.(@id == 1 || @id == 2));
|
||||
|
||||
// name of employee with id 1
|
||||
print("Name of the the employee with ID=1: " + e.employee.(@id == 1).name);
|
||||
@@ -184,7 +184,3 @@ print("Name of the the employee with ID=1: " + e.employee.(@id == 1).name);
|
||||
print("----------------------------------------");
|
||||
|
||||
openConsole();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
log("Hello world!!!");
|
||||
toast("Hello, AutoJs!");
|
||||
console.show();
|
||||
log('Hello world!!!');
|
||||
toast('Hello, AutoJs!');
|
||||
console.show();
|
||||
|
||||
@@ -3,5 +3,5 @@ b = 6;
|
||||
c = -1;
|
||||
x = 1.5;
|
||||
y = a * x * x + b * x * c;
|
||||
log("y = " + y);
|
||||
log('y = ' + y);
|
||||
openConsole();
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
|
||||
// 回收图片
|
||||
img.recycle();
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// 创建检测器
|
||||
let predictor = new Predictor();
|
||||
|
||||
// predictor.cpuThreadNum = 4 //可以自定义使用CPU的线程数
|
||||
// predictor.checkModelLoaded = false // 可以自定义是否需要校验模型是否成功加载 默认开启 使用内置Base64图片进行校验 识别测试文本来校验模型是否加载成功
|
||||
// predictor.cpuThreadNum = 4 // 可以自定义使用 CPU 的线程数
|
||||
// predictor.checkModelLoaded = false // 可以自定义是否需要校验模型是否成功加载 默认开启 使用内置 Base64 图片进行校验 识别测试文本来校验模型是否加载成功
|
||||
|
||||
// 初始化模型 首次运行时会比较耗时
|
||||
let loading = threads.disposable();
|
||||
@@ -22,11 +22,11 @@
|
||||
threads.start(function () {
|
||||
loading.setAndNotify(predictor.init(context, useSlim));
|
||||
// loading.setAndNotify(predictor.init(context)) 为默认不使用精简版
|
||||
// 内置默认 modelPath 为 models/ocr_v3_for_cpu,初始化自定义模型请写绝对路径否则无法获取到
|
||||
// 内置默认 modelPath 为 models/ocr_v3_for_cpu, 初始化自定义模型请写绝对路径否则无法获取到
|
||||
// 内置默认 labelPath 为 labels/ppocr_keys_v1.txt
|
||||
// let modelPath = files.path('./models/customize') // 指定自定义模型路径
|
||||
// let labelPath = files.path('./models/customize') // 指定自定义label路径
|
||||
// 使用自定义模型时det rec cls三个模型文件名称需要手动指定
|
||||
// let labelPath = files.path('./models/customize') // 指定自定义 label 路径
|
||||
// 使用自定义模型时 det rec cls 三个模型文件名称需要手动指定
|
||||
// predictor.detModelFilename = 'det_opt.nb'
|
||||
// predictor.recModelFilename = 'rec_opt.nb'
|
||||
// predictor.clsModelFilename = 'cls_opt.nb'
|
||||
@@ -34,21 +34,21 @@
|
||||
});
|
||||
|
||||
let loadSuccess = loading.blockedGet();
|
||||
toastLog(`加载模型结果:${loadSuccess}`);
|
||||
toastLog(`加载模型结果: ${loadSuccess}`);
|
||||
|
||||
let start = new Date();
|
||||
let img = images.read('test.png');
|
||||
let results = predictor.runOcr(img.getBitmap());
|
||||
|
||||
toastLog(`识别结束, 耗时:${new Date() - start}ms`);
|
||||
toastLog(`识别结束, 耗时: ${new Date() - start}ms`);
|
||||
|
||||
log(`识别结果: ${JSON.stringify(results.toArray().map((result) => {
|
||||
return { label: result.label, confidence: result.confidence, bounds: result.bounds };
|
||||
}))}`);
|
||||
|
||||
// 释放模型 用于释放native内存 非必需
|
||||
// 释放模型 用于释放 native 内存, 非必需
|
||||
// predictor.releaseModel()
|
||||
|
||||
// 回收图片
|
||||
img.recycle();
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
// 创建检测器
|
||||
let predictor = new Predictor();
|
||||
|
||||
// predictor.cpuThreadNum = 4 // 可以自定义使用CPU的线程数
|
||||
// predictor.checkModelLoaded = false // 可以自定义是否需要校验模型是否成功加载 默认开启 使用内置Base64图片进行校验 识别测试文本来校验模型是否加载成功
|
||||
// predictor.cpuThreadNum = 4 // 可以自定义使用 CPU 的线程数
|
||||
// predictor.checkModelLoaded = false // 可以自定义是否需要校验模型是否成功加载 默认开启 使用内置 Base64 图片进行校验 识别测试文本来校验模型是否加载成功
|
||||
|
||||
// 初始化模型 首次运行时会比较耗时
|
||||
let loading = threads.disposable();
|
||||
@@ -41,11 +41,11 @@
|
||||
threads.start(function () {
|
||||
loading.setAndNotify(predictor.init(context, useSlim));
|
||||
// loading.setAndNotify(predictor.init(context)) 为默认不使用精简版
|
||||
// 内置默认 modelPath 为 models/ocr_v3_for_cpu,初始化自定义模型请写绝对路径否则无法获取到
|
||||
// 内置默认 modelPath 为 models/ocr_v3_for_cpu, 初始化自定义模型请写绝对路径否则无法获取到
|
||||
// 内置默认 labelPath 为 labels/ppocr_keys_v1.txt
|
||||
// let modelPath = files.path('./models/customize') // 指定自定义模型路径
|
||||
// let labelPath = files.path('./models/customize') // 指定自定义label路径
|
||||
// 使用自定义模型时det rec cls三个模型文件名称需要手动指定
|
||||
// let labelPath = files.path('./models/customize') // 指定自定义 label 路径
|
||||
// 使用自定义模型时 det rec cls 三个模型文件名称需要手动指定
|
||||
// predictor.detModelFilename = 'det_opt.nb'
|
||||
// predictor.recModelFilename = 'rec_opt.nb'
|
||||
// predictor.clsModelFilename = 'cls_opt.nb'
|
||||
@@ -53,7 +53,7 @@
|
||||
});
|
||||
let loadSuccess = loading.blockedGet();
|
||||
if (!loadSuccess) {
|
||||
toastLog('初始化ocr失败');
|
||||
toastLog('初始化 ocr 失败');
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
let capturing = true;
|
||||
|
||||
/**
|
||||
* 截图并识别OCR文本信息
|
||||
* 截图并识别 OCR 文本信息
|
||||
*/
|
||||
function captureAndOcr() {
|
||||
capturing = true;
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
let start = new Date();
|
||||
result = predictor.runOcr(img.getBitmap());
|
||||
toastLog(`耗时${new Date() - start}ms`);
|
||||
toastLog(`耗时 ${new Date() - start}ms`);
|
||||
capturing = false;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
/* Empty body. */
|
||||
}, 10000);
|
||||
events.on('exit', () => {
|
||||
// 标记停止 避免canvas导致闪退
|
||||
// 标记停止 避免 canvas 导致闪退
|
||||
running = false;
|
||||
// 撤销监听
|
||||
window.canvas.removeAllListeners();
|
||||
@@ -195,4 +195,4 @@
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}();
|
||||
}();
|
||||
|
||||
@@ -1 +1 @@
|
||||
shell("pm disable com.netease.cloudmusic", true);
|
||||
shell('pm disable com.netease.cloudmusic', true);
|
||||
|
||||
@@ -1 +1 @@
|
||||
shell("am kill-all", true);
|
||||
shell('am kill-all', true);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
shell("pm enable com.netease.cloudmusic", true);
|
||||
launchApp("网易云音乐");
|
||||
shell('pm enable com.netease.cloudmusic', true);
|
||||
launchApp('网易云音乐');
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
KeyCode("KEYCODE_POWER");
|
||||
//或者 KeyCode(26);
|
||||
// 或者 KeyCode(26);
|
||||
KeyCode('KEYCODE_POWER');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
auto();
|
||||
events.observeToast();
|
||||
events.onToast(function(toast){
|
||||
events.onToast(function (toast) {
|
||||
var pkg = toast.getPackageName();
|
||||
log("Toast内容: " + toast.getText() +
|
||||
" 来自: " + getAppName(pkg) +
|
||||
" 包名: " + pkg);
|
||||
log('Toast 内容: ' + toast.getText() +
|
||||
' 来自: ' + getAppName(pkg) +
|
||||
' 包名: ' + pkg);
|
||||
});
|
||||
toast("监听中,请在日志中查看记录的Toast及其内容");
|
||||
toast('监听中, 请在日志中查看记录的 Toast 及其内容');
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
"auto";
|
||||
'auto';
|
||||
|
||||
events.observeKey();
|
||||
|
||||
var keyNames = {
|
||||
"KEYCODE_VOLUME_UP": "音量上键",
|
||||
"KEYCODE_VOLUME_DOWN": "音量下键",
|
||||
"KEYCODE_HOME": "Home键",
|
||||
"KEYCODE_BACK": "返回键",
|
||||
"KEYCODE_MENU": "菜单键",
|
||||
"KEYCODE_POWER": "电源键",
|
||||
'KEYCODE_VOLUME_UP': '音量上键',
|
||||
'KEYCODE_VOLUME_DOWN': '音量下键',
|
||||
'KEYCODE_HOME': 'Home 键',
|
||||
'KEYCODE_BACK': '返回键',
|
||||
'KEYCODE_MENU': '菜单键',
|
||||
'KEYCODE_POWER': '电源键',
|
||||
};
|
||||
|
||||
events.on("key", function(code, event){
|
||||
events.on('key', function (code, event) {
|
||||
var keyName = getKeyName(code, event);
|
||||
if(event.getAction() === event.ACTION_DOWN){
|
||||
toast(keyName + "被按下");
|
||||
}else if(event.getAction() === event.ACTION_UP){
|
||||
toast(keyName + "弹起");
|
||||
if (event.getAction() === event.ACTION_DOWN) {
|
||||
toast(keyName + '被按下');
|
||||
} else if (event.getAction() === event.ACTION_UP) {
|
||||
toast(keyName + '弹起');
|
||||
}
|
||||
});
|
||||
|
||||
// loop();
|
||||
|
||||
function getKeyName(code, event){
|
||||
function getKeyName(code, event) {
|
||||
var keyCodeStr = event.keyCodeToString(code);
|
||||
var keyName = keyNames[keyCodeStr];
|
||||
if(!keyName){
|
||||
if (!keyName) {
|
||||
return keyCodeStr;
|
||||
}
|
||||
return keyName;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
events.observeTouch();
|
||||
|
||||
events.setTouchEventTimeout(30);
|
||||
|
||||
toast("请在日志中查看触摸的点的坐标");
|
||||
toast('请在日志中查看触摸的点的坐标');
|
||||
|
||||
events.on("touch", function(point){
|
||||
events.on('touch', function (point) {
|
||||
log(point);
|
||||
});
|
||||
|
||||
// loop();
|
||||
// loop();
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
auto();
|
||||
events.observeNotification();
|
||||
events.onNotification(function(notification){
|
||||
events.onNotification(function (notification) {
|
||||
printNotification(notification);
|
||||
});
|
||||
toast("监听中,请在日志中查看记录的通知及其内容");
|
||||
toast('监听中, 请在日志中查看记录的通知及其内容');
|
||||
|
||||
function printNotification(notification){
|
||||
log("应用包名: " + notification.getPackageName());
|
||||
log("通知文本: " + notification.getText());
|
||||
log("通知优先级: " + notification.priority);
|
||||
log("通知目录: " + notification.category);
|
||||
log("通知时间: " + new Date(notification.when));
|
||||
log("通知数: " + notification.number);
|
||||
log("通知摘要: " + notification.tickerText);
|
||||
}
|
||||
function printNotification(notification) {
|
||||
log('应用包名: ' + notification.getPackageName());
|
||||
log('通知文本: ' + notification.getText());
|
||||
log('通知优先级: ' + notification.priority);
|
||||
log('通知目录: ' + notification.category);
|
||||
log('通知时间: ' + new Date(notification.when));
|
||||
log('通知数: ' + notification.number);
|
||||
log('通知摘要: ' + notification.tickerText);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
"auto";
|
||||
'auto';
|
||||
|
||||
var 长按间隔 = 1500;
|
||||
var delayDuration = 1500;
|
||||
|
||||
var curPackage = null;
|
||||
var timeoutId = null;
|
||||
|
||||
events.observeKey();
|
||||
|
||||
events.onKeyDown("back", function(event){
|
||||
events.onKeyDown('back', function (event) {
|
||||
curPackage = currentPackage();
|
||||
timeoutId = setTimeout(function(){
|
||||
backBackBackBack();
|
||||
}, 长按间隔);
|
||||
timeoutId = setTimeout(function () {
|
||||
backBackBackBack();
|
||||
}, delayDuration);
|
||||
});
|
||||
|
||||
events.onKeyUp("back", function(event){
|
||||
events.onKeyUp('back', function (event) {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
|
||||
// loop();
|
||||
|
||||
function backBackBackBack(){
|
||||
while(curPackage === currentPackage()){
|
||||
function backBackBackBack() {
|
||||
while (curPackage === currentPackage()) {
|
||||
back();
|
||||
sleep(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ events.setKeyInterceptionEnabled(true);
|
||||
events.on('volume_down', () => {
|
||||
app.sendBroadcast('bounds');
|
||||
exit();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
"auto";
|
||||
'auto';
|
||||
|
||||
events.observeKey();
|
||||
|
||||
var interval = 5000;
|
||||
var task = task1;
|
||||
|
||||
events.onKeyDown("volume_up", function(event){
|
||||
if(task === task1){
|
||||
events.onKeyDown('volume_up', function (event) {
|
||||
if (task === task1) {
|
||||
task = task2;
|
||||
}else{
|
||||
} else {
|
||||
task = task1;
|
||||
}
|
||||
toast("任务已切换");
|
||||
toast('任务已切换');
|
||||
});
|
||||
|
||||
events.onKeyDown("volume_down", function(event){
|
||||
toast("程序结束");
|
||||
events.onKeyDown('volume_down', function (event) {
|
||||
toast('程序结束');
|
||||
exit();
|
||||
});
|
||||
|
||||
@@ -23,12 +23,12 @@ task();
|
||||
|
||||
// loop();
|
||||
|
||||
function task1(){
|
||||
toast("任务1运行中,音量下键结束,音量上键切换任务");
|
||||
function task1() {
|
||||
toast('任务 1 运行中, 音量下键结束, 音量上键切换任务');
|
||||
setTimeout(task, interval);
|
||||
}
|
||||
|
||||
function task2(){
|
||||
toast("任务2运行中,音量下键结束,音量上键切换任务");
|
||||
function task2() {
|
||||
toast('任务 2 运行中, 音量下键结束, 音量上键切换任务');
|
||||
setTimeout(task, interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ tasks.addDisposableTask({
|
||||
},
|
||||
});
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -7,7 +7,7 @@ tasks.addIntentTask({
|
||||
console.log(`意图动作: ${task.action}`);
|
||||
console.log(`脚本路径: ${task.scriptPath}`);
|
||||
console.info('可在 AutoJs6 任务面板查看或管理任务');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tasks.addWeeklyTask({
|
||||
time: Date.now() + 3.6e6 * 12,
|
||||
path: files.path('./test.js'),
|
||||
daysOfWeek: ['六', 3, 'Fri', 'Sunday'],
|
||||
daysOfWeek: [ '六', 3, 'Fri', 'Sunday' ],
|
||||
callback(task) {
|
||||
console.log(`已添加的每周任务: ${task}`);
|
||||
console.log(`ID: ${task.id}`);
|
||||
@@ -12,4 +12,4 @@ tasks.addWeeklyTask({
|
||||
},
|
||||
});
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -10,4 +10,4 @@ tasks.addDailyTask({
|
||||
},
|
||||
});
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
//忽略不支持的传感器,即使有传感器不支持也不抛出异常
|
||||
// 忽略不支持的传感器, 即使有传感器不支持也不抛出异常
|
||||
sensors.ignoresUnsupportedSensor = true;
|
||||
|
||||
sensors.on("unsupported_sensor", function(sensorName, sensorType){
|
||||
log("不支持的传感器: %s 类型: %d", sensorName, sensorType);
|
||||
sensors.on('unsupported_sensor', function (sensorName, sensorType) {
|
||||
log('不支持的传感器: %s 类型: %d', sensorName, sensorType);
|
||||
});
|
||||
|
||||
//加速度传感器
|
||||
sensors.register("accelerometer").on("change", (event, ax, ay, az)=>{
|
||||
log("x方向加速度: %d\ny方向加速度: %d\nz方向加速度: %d", ax, ay, az);
|
||||
// 加速度传感器
|
||||
sensors.register('accelerometer').on('change', (event, ax, ay, az) => {
|
||||
log('x 方向加速度: %d\ny 方向加速度: %d\nz 方向加速度: %d', ax, ay, az);
|
||||
});
|
||||
//方向传感器
|
||||
sensors.register("orientation").on("change", (event, dx, dy, dz)=>{
|
||||
log("绕x轴转过角度: %d\n绕y轴转过角度: %d\n绕z轴转过角度: %d", dx, dy, dz);
|
||||
// 方向传感器
|
||||
sensors.register('orientation').on('change', (event, dx, dy, dz) => {
|
||||
log('绕 x 轴转过角度: %d\n 绕 y 轴转过角度: %d\n 绕 z 轴转过角度: %d', dx, dy, dz);
|
||||
});
|
||||
//陀螺仪传感器
|
||||
sensors.register("gyroscope").on("change", (event, wx, wy, wz)=>{
|
||||
log("绕x轴角速度: %d\n绕y轴角速度: %d\n绕z轴角速度: %d", wx, wy, wz);
|
||||
// 陀螺仪传感器
|
||||
sensors.register('gyroscope').on('change', (event, wx, wy, wz) => {
|
||||
log('绕 x 轴角速度: %d\n 绕 y 轴角速度: %d\n 绕 z 轴角速度: %d', wx, wy, wz);
|
||||
});
|
||||
//磁场传感器
|
||||
sensors.register("magnetic_field").on("change", (event, bx, by, bz)=>{
|
||||
log("x方向磁场强度: %d\ny方向磁场强度: %d\nz方向磁场强度: %d", bx, by, bz);
|
||||
// 磁场传感器
|
||||
sensors.register('magnetic_field').on('change', (event, bx, by, bz) => {
|
||||
log('x 方向磁场强度: %d\ny 方向磁场强度: %d\nz 方向磁场强度: %d', bx, by, bz);
|
||||
});
|
||||
//重力传感器
|
||||
sensors.register("magnetic_field").on("change", (event, gx, gy, gz)=>{
|
||||
log("x方向重力: %d\ny方向重力: %d\nz方向重力: %d", gx, gy, gz);
|
||||
// 重力传感器
|
||||
sensors.register('magnetic_field').on('change', (event, gx, gy, gz) => {
|
||||
log('x 方向重力: %d\ny 方向重力: %d\nz 方向重力: %d', gx, gy, gz);
|
||||
});
|
||||
//线性加速度传感器
|
||||
sensors.register("linear_acceleration").on("change", (event, ax, ay, az)=>{
|
||||
log("x方向线性加速度: %d\ny方向线性加速度: %d\nz方向线性加速度: %d", ax, ay, az);
|
||||
// 线性加速度传感器
|
||||
sensors.register('linear_acceleration').on('change', (event, ax, ay, az) => {
|
||||
log('x 方向线性加速度: %d\ny 方向线性加速度: %d\nz 方向线性加速度: %d', ax, ay, az);
|
||||
});
|
||||
//温度传感器
|
||||
sensors.register("ambient_temperature").on("change", (event, t)=>{
|
||||
log("当前温度: %d", t);
|
||||
// 温度传感器
|
||||
sensors.register('ambient_temperature').on('change', (event, t) => {
|
||||
log('当前温度: %d', t);
|
||||
});
|
||||
//光线传感器
|
||||
sensors.register("light").on("change", (event, l)=>{
|
||||
log("当前光的强度: %d", l);
|
||||
// 光线传感器
|
||||
sensors.register('light').on('change', (event, l) => {
|
||||
log('当前光的强度: %d', l);
|
||||
});
|
||||
//压力传感器
|
||||
sensors.register("pressure").on("change", (event, p)=>{
|
||||
log("当前压力: %d", p);
|
||||
// 压力传感器
|
||||
sensors.register('pressure').on('change', (event, p) => {
|
||||
log('当前压力: %d', p);
|
||||
});
|
||||
//距离传感器
|
||||
sensors.register("proximity").on("change", (event, d)=>{
|
||||
log("当前距离: %d", d);
|
||||
// 距离传感器
|
||||
sensors.register('proximity').on('change', (event, d) => {
|
||||
log('当前距离: %d', d);
|
||||
});
|
||||
//湿度传感器
|
||||
sensors.register("relative_humidity").on("change", (event, rh)=>{
|
||||
log("当前相对湿度: %d", rh);
|
||||
// 湿度传感器
|
||||
sensors.register('relative_humidity').on('change', (event, rh) => {
|
||||
log('当前相对湿度: %d', rh);
|
||||
});
|
||||
|
||||
//30秒后退出程序
|
||||
// 30 秒后退出程序
|
||||
setTimeout(exit, 30 * 1000);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<scroll>
|
||||
@@ -15,60 +15,60 @@ ui.layout(
|
||||
<text id="proximity" margin="12dp" textSize="16sp" textColor="#000000"/>
|
||||
<text id="relative_humidity" margin="12dp" textSize="16sp" textColor="#000000"/>
|
||||
</vertical>
|
||||
</scroll>
|
||||
</scroll>,
|
||||
);
|
||||
|
||||
//忽略不支持的传感器,即使有传感器不支持也不抛出异常
|
||||
// 忽略不支持的传感器, 即使有传感器不支持也不抛出异常
|
||||
sensors.ignoresUnsupportedSensor = true;
|
||||
|
||||
sensors.on("unsupported_sensor", function(sensorName, sensorType){
|
||||
log(util.format("不支持的传感器: %s 类型: %d", sensorName, sensorType));
|
||||
sensors.on('unsupported_sensor', function (sensorName, sensorType) {
|
||||
log(util.format('不支持的传感器: %s 类型: %d', sensorName, sensorType));
|
||||
});
|
||||
|
||||
//加速度传感器
|
||||
sensors.register("accelerometer", sensors.delay.ui).on("change", (event, ax, ay, az)=>{
|
||||
ui.accelerometer.setText(util.format("x方向加速度: %d\ny方向加速度: %d\nz方向加速度: %d", ax, ay, az));
|
||||
// 加速度传感器
|
||||
sensors.register('accelerometer', sensors.delay.ui).on('change', (event, ax, ay, az) => {
|
||||
ui.accelerometer.setText(util.format('x 方向加速度: %d\ny 方向加速度: %d\nz 方向加速度: %d', ax, ay, az));
|
||||
});
|
||||
//方向传感器
|
||||
sensors.register("orientation", sensors.delay.ui).on("change", (event, dx, dy, dz)=>{
|
||||
ui.orientation.setText(util.format("绕x轴转过角度: %d\n绕y轴转过角度: %d\n绕z轴转过角度: %d", dx, dy, dz));
|
||||
// 方向传感器
|
||||
sensors.register('orientation', sensors.delay.ui).on('change', (event, dx, dy, dz) => {
|
||||
ui.orientation.setText(util.format('绕 x 轴转过角度: %d\n 绕 y 轴转过角度: %d\n 绕 z 轴转过角度: %d', dx, dy, dz));
|
||||
});
|
||||
//陀螺仪传感器
|
||||
sensors.register("gyroscope", sensors.delay.ui).on("change", (event, wx, wy, wz)=>{
|
||||
ui.gyroscope.setText(util.format("绕x轴角速度: %d\n绕y轴角速度: %d\n绕z轴角速度: %d", wx, wy, wz));
|
||||
// 陀螺仪传感器
|
||||
sensors.register('gyroscope', sensors.delay.ui).on('change', (event, wx, wy, wz) => {
|
||||
ui.gyroscope.setText(util.format('绕 x 轴角速度: %d\n 绕 y 轴角速度: %d\n 绕 z 轴角速度: %d', wx, wy, wz));
|
||||
});
|
||||
//磁场传感器
|
||||
sensors.register("magnetic_field", sensors.delay.ui).on("change", (event, bx, by, bz)=>{
|
||||
ui.magnetic_field.setText(util.format("x方向磁场强度: %d\ny方向磁场强度: %d\nz方向磁场强度: %d", bx, by, bz));
|
||||
// 磁场传感器
|
||||
sensors.register('magnetic_field', sensors.delay.ui).on('change', (event, bx, by, bz) => {
|
||||
ui.magnetic_field.setText(util.format('x 方向磁场强度: %d\ny 方向磁场强度: %d\nz 方向磁场强度: %d', bx, by, bz));
|
||||
});
|
||||
//重力传感器
|
||||
sensors.register("gravity", sensors.delay.ui).on("change", (event, gx, gy, gz)=>{
|
||||
ui.gravity.setText(util.format("x方向重力: %d\ny方向重力: %d\nz方向重力: %d", gx, gy, gz));
|
||||
// 重力传感器
|
||||
sensors.register('gravity', sensors.delay.ui).on('change', (event, gx, gy, gz) => {
|
||||
ui.gravity.setText(util.format('x 方向重力: %d\ny 方向重力: %d\nz 方向重力: %d', gx, gy, gz));
|
||||
});
|
||||
//线性加速度传感器
|
||||
sensors.register("linear_acceleration", sensors.delay.ui).on("change", (event, ax, ay, az)=>{
|
||||
ui.linear_acceleration.setText(util.format("x方向线性加速度: %d\ny方向线性加速度: %d\nz方向线性加速度: %d", ax, ay, az));
|
||||
// 线性加速度传感器
|
||||
sensors.register('linear_acceleration', sensors.delay.ui).on('change', (event, ax, ay, az) => {
|
||||
ui.linear_acceleration.setText(util.format('x 方向线性加速度: %d\ny 方向线性加速度: %d\nz 方向线性加速度: %d', ax, ay, az));
|
||||
});
|
||||
//温度传感器
|
||||
sensors.register("ambient_temperature", sensors.delay.ui).on("change", (event, t)=>{
|
||||
ui.ambient_temperature.setText(util.format("当前温度: %d", t));
|
||||
// 温度传感器
|
||||
sensors.register('ambient_temperature', sensors.delay.ui).on('change', (event, t) => {
|
||||
ui.ambient_temperature.setText(util.format('当前温度: %d', t));
|
||||
});
|
||||
//光线传感器
|
||||
sensors.register("light", sensors.delay.ui).on("change", (event, l)=>{
|
||||
ui.light.setText(util.format("当前光的强度: %d", l));
|
||||
// 光线传感器
|
||||
sensors.register('light', sensors.delay.ui).on('change', (event, l) => {
|
||||
ui.light.setText(util.format('当前光的强度: %d', l));
|
||||
});
|
||||
//压力传感器
|
||||
sensors.register("pressure", sensors.delay.ui).on("change", (event, p)=>{
|
||||
ui.pressure.setText(util.format("当前压力: %d", p));
|
||||
// 压力传感器
|
||||
sensors.register('pressure', sensors.delay.ui).on('change', (event, p) => {
|
||||
ui.pressure.setText(util.format('当前压力: %d', p));
|
||||
});
|
||||
//距离传感器
|
||||
sensors.register("proximity", sensors.delay.ui).on("change", (event, d)=>{
|
||||
ui.proximity.setText(util.format("当前距离: %d", d));
|
||||
// 距离传感器
|
||||
sensors.register('proximity', sensors.delay.ui).on('change', (event, d) => {
|
||||
ui.proximity.setText(util.format('当前距离: %d', d));
|
||||
});
|
||||
//湿度传感器
|
||||
sensors.register("relative_humidity", sensors.delay.ui).on("change", (event, rh)=>{
|
||||
ui.relative_humidity.setText(util.format("当前相对湿度: %d", rh));
|
||||
// 湿度传感器
|
||||
sensors.register('relative_humidity', sensors.delay.ui).on('change', (event, rh) => {
|
||||
ui.relative_humidity.setText(util.format('当前相对湿度: %d', rh));
|
||||
});
|
||||
|
||||
//30秒后退出程序
|
||||
// 30 秒后退出程序
|
||||
setTimeout(exit, 30 * 1000);
|
||||
|
||||
@@ -21,4 +21,4 @@ ui.emitter.on('back_pressed', function (e) {
|
||||
if (exit) {
|
||||
ui.finish();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit();
|
||||
}
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
//指定在位置(100, 220)宽高为400*400的区域找色。
|
||||
//#75438a是编辑器默认主题的棕红色字体(数字)颜色,位置大约在第5行的"2000",坐标大约为(283, 465)
|
||||
var point = findColorInRegion(img, "#75438a", 90, 220, 900, 1000);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
toastLog('开始找色');
|
||||
// 指定在位置 (100, 220) 宽高为 400 × 400 的区域找色.
|
||||
// #75438a 是编辑器默认主题的棕红色字体 (数字) 颜色, 位置大约在第 5 行的 "2000", 坐标大约为 (283, 465)
|
||||
var point = findColorInRegion(img, '#75438a', 90, 220, 900, 1000);
|
||||
if (point) {
|
||||
toastLog('x = ' + point.x + ', y = ' + point.y);
|
||||
} else {
|
||||
toastLog('没有找到');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0xffffff为白色
|
||||
toastLog("开始找色");
|
||||
//指定在位置(90, 220)宽高为900*1000的区域找色。
|
||||
//0xff00cc是编辑器的深粉红色字体(字符串)颜色
|
||||
var point = findColor(img, "#ff00cc", {
|
||||
region: [90, 220, 900, 1000],
|
||||
threads: 8
|
||||
// 0xffffff 为白色
|
||||
toastLog('开始找色');
|
||||
// 指定在位置 (90, 220) 宽高为 900 × 1000 的区域找色.
|
||||
// 0xff00cc 是编辑器的深粉红色字体 (字符串) 颜色.
|
||||
var point = findColor(img, '#ff00cc', {
|
||||
region: [ 90, 220, 900, 1000 ],
|
||||
threads: 8,
|
||||
});
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
if (point) {
|
||||
toastLog('x = ' + point.x + ', y = ' + point.y);
|
||||
} else {
|
||||
toastLog('没有找到');
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
var url = "https://www.autojs.org/assets/uploads/files/1540386817060-918021-20160416200702191-185324559.jpg";
|
||||
var url = 'https://www.autojs.org/assets/uploads/files/1540386817060-918021-20160416200702191-185324559.jpg';
|
||||
var logo = null;
|
||||
var currentImg = null;
|
||||
|
||||
events.on("exit", function(){
|
||||
if(logo){
|
||||
events.on('exit', function () {
|
||||
if (logo) {
|
||||
logo.recycle();
|
||||
}
|
||||
if(currentImg){
|
||||
if (currentImg) {
|
||||
currentImg.recycle();
|
||||
}
|
||||
});
|
||||
|
||||
ui.layout(
|
||||
<vertical>
|
||||
<img id="img" w="250" h="250" url="{{url}}" />
|
||||
<img id="img" w="250" h="250" url="{{url}}"/>
|
||||
<scroll>
|
||||
<vertical>
|
||||
<button id="rotate" text="旋转" />
|
||||
<button id="concat" text="拼接" />
|
||||
<button id="grayscale" text="灰度化" />
|
||||
<button id="binary" text="二值化" />
|
||||
<button id="adaptiveBinary" text="自适应二值化" />
|
||||
<button id="hsv" text="RGB转HSV" />
|
||||
<button id="blur" text="模糊" />
|
||||
<button id="medianBlur" text="中值滤波" />
|
||||
<button id="gaussianBlur" text="高斯模糊" />
|
||||
<button id="rotate" text="旋转"/>
|
||||
<button id="concat" text="拼接"/>
|
||||
<button id="grayscale" text="灰度化"/>
|
||||
<button id="binary" text="二值化"/>
|
||||
<button id="adaptiveBinary" text="自适应二值化"/>
|
||||
<button id="hsv" text="RGB 转 HSV"/>
|
||||
<button id="blur" text="模糊"/>
|
||||
<button id="medianBlur" text="中值滤波"/>
|
||||
<button id="gaussianBlur" text="高斯模糊"/>
|
||||
</vertical>
|
||||
</scroll>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
//把一张图片设置到图片控件中
|
||||
// 把一张图片设置到图片控件中
|
||||
function setImage(img) {
|
||||
ui.run(() => {
|
||||
ui.img.setImageBitmap(img.bitmap);
|
||||
var oldImg = currentImg;
|
||||
//不能立即回收currentImg,因为此时img控件还在使用它,应该在下次消息循环再回收它
|
||||
ui.post(()=>{
|
||||
if(oldImg){
|
||||
// 不能立即回收 currentImg, 因为此时 img 控件还在使用它, 应该在下次消息循环再回收它
|
||||
ui.post(() => {
|
||||
if (oldImg) {
|
||||
oldImg.recycle();
|
||||
}
|
||||
});
|
||||
@@ -47,96 +47,97 @@ function setImage(img) {
|
||||
});
|
||||
}
|
||||
|
||||
//启动一个处理图片的线程
|
||||
// 启动一个处理图片的线程
|
||||
var imgProcess = threads.start(function () {
|
||||
setInterval(() => { }, 1000);
|
||||
setInterval(() => {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
//处理图片的函数,把任务交给图片处理线程处理
|
||||
// 处理图片的函数, 把任务交给图片处理线程处理
|
||||
function processImg(process) {
|
||||
imgProcess.setTimeout(() => {
|
||||
if (!logo) {
|
||||
logo = images.load(url);
|
||||
}
|
||||
//处理图片
|
||||
// 处理图片
|
||||
var result = process(logo);
|
||||
//把处理后的图片设置到图片控件中
|
||||
// 把处理后的图片设置到图片控件中
|
||||
setImage(result);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var degress = 0;
|
||||
|
||||
ui.rotate.on("click", () => {
|
||||
ui.rotate.on('click', () => {
|
||||
processImg(img => {
|
||||
degress += 90;
|
||||
//旋转degress角度
|
||||
// 旋转 degress 角度
|
||||
return images.rotate(img, degress);
|
||||
});
|
||||
});
|
||||
|
||||
ui.concat.on("click", () => {
|
||||
ui.concat.on('click', () => {
|
||||
processImg(img => {
|
||||
if(!currentImg){
|
||||
toast("请先点击其他按钮,再点击本按钮");
|
||||
if (!currentImg) {
|
||||
toast('请先点击其他按钮, 再点击本按钮');
|
||||
return img.clone();
|
||||
}
|
||||
//把currentImg拼接在img右边
|
||||
return images.concat(img, currentImg, "right");
|
||||
// 把 currentImg 拼接在 img 右边
|
||||
return images.concat(img, currentImg, 'right');
|
||||
});
|
||||
});
|
||||
|
||||
ui.grayscale.on("click", () => {
|
||||
ui.grayscale.on('click', () => {
|
||||
processImg(img => {
|
||||
//灰度化
|
||||
// 灰度化
|
||||
return images.grayscale(img);
|
||||
});
|
||||
});
|
||||
|
||||
ui.binary.on("click", () => {
|
||||
ui.binary.on('click', () => {
|
||||
processImg(img => {
|
||||
var g = images.grayscale(img);
|
||||
//二值化,取灰度为30到200之间的图片
|
||||
// 二值化, 取灰度为 30 到 200 之间的图片
|
||||
var result = images.threshold(g, 100, 200);
|
||||
g.recycle();
|
||||
return result;
|
||||
});
|
||||
});
|
||||
|
||||
ui.adaptiveBinary.on("click", () => {
|
||||
ui.adaptiveBinary.on('click', () => {
|
||||
processImg(img => {
|
||||
var g = images.grayscale(img);
|
||||
//自适应二值化,最大值为200,块大小为25
|
||||
var result = images.adaptiveThreshold(g, 200, "MEAN_C", "BINARY", 25, 10);
|
||||
// 自适应二值化, 最大值为 200, 块大小为 25
|
||||
var result = images.adaptiveThreshold(g, 200, 'MEAN_C', 'BINARY', 25, 10);
|
||||
g.recycle();
|
||||
return result;
|
||||
});
|
||||
});
|
||||
|
||||
ui.hsv.on("click", () => {
|
||||
ui.hsv.on('click', () => {
|
||||
processImg(img => {
|
||||
//RGB转HSV
|
||||
return images.cvtColor(img, "BGR2HSV");
|
||||
// RGB 转 HSV
|
||||
return images.cvtColor(img, 'BGR2HSV');
|
||||
});
|
||||
});
|
||||
|
||||
ui.blur.on("click", () => {
|
||||
ui.blur.on('click', () => {
|
||||
processImg(img => {
|
||||
//模糊
|
||||
return images.blur(img, [10, 10]);
|
||||
// 模糊
|
||||
return images.blur(img, [ 10, 10 ]);
|
||||
});
|
||||
});
|
||||
|
||||
ui.medianBlur.on("click", () => {
|
||||
ui.medianBlur.on('click', () => {
|
||||
processImg(img => {
|
||||
//中值滤波
|
||||
// 中值滤波
|
||||
return images.medianBlur(img, 5);
|
||||
});
|
||||
});
|
||||
|
||||
ui.gaussianBlur.on("click", () => {
|
||||
ui.gaussianBlur.on('click', () => {
|
||||
processImg(img => {
|
||||
//高斯模糊
|
||||
return images.gaussianBlur(img, [5, 5]);
|
||||
// 高斯模糊
|
||||
return images.gaussianBlur(img, [ 5, 5 ]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ let cA = colors.alpha(color);
|
||||
|
||||
console.log(`Color string: ${color}`);
|
||||
console.log(`Color int: ${colorInt}`);
|
||||
console.log(`Color rgba: [ ${[`R: ${cR}`, `G: ${cG}`, `B: ${cB}`, `A: ${cA}`].join(', ')} ]`);
|
||||
console.log(`Color rgba: [ ${[ `R: ${cR}`, `G: ${cG}`, `B: ${cB}`, `A: ${cA}` ].join(', ')} ]`);
|
||||
|
||||
let test = o => console.log(`Test instance ${o ? `passed` : `failed`}`);
|
||||
|
||||
@@ -22,4 +22,4 @@ test(colors.toString(color) === colors.toString(colorInt));
|
||||
test(colors.toString('#224466') === colors.toString('#FF224466', 6 /* none */));
|
||||
test(colors.toString('#FF224466') === colors.toString('#224466', 8 /* keep */));
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -2,7 +2,7 @@ requestScreenCapture();
|
||||
console.show();
|
||||
events.observeTouch();
|
||||
events.setTouchEventTimeout(30);
|
||||
events.on("touch", function(point){
|
||||
events.on('touch', function (point) {
|
||||
var c = colors.toString(images.pixel(captureScreen(), point.x, point.y));
|
||||
log("(" + point.x + ", " + point.y + "): " + c);
|
||||
});
|
||||
log('(' + point.x + ', ' + point.y + '): ' + c);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit();
|
||||
}
|
||||
var img = captureScreen();
|
||||
images.saveImage(img, "/sdcard/1.png");
|
||||
images.saveImage(img, '/sdcard/1.png');
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit();
|
||||
}
|
||||
launchApp("QQ");
|
||||
launchApp('QQ');
|
||||
sleep(2000);
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
var point = findColor(img, "#f64d30");
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
toastLog('开始找色');
|
||||
var point = findColor(img, '#f64d30');
|
||||
if (point) {
|
||||
toastLog('x = ' + point.x + ', y = ' + point.y);
|
||||
} else {
|
||||
toastLog('没有找到');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
var superMario = images.read("./super_mario.jpg");
|
||||
var block = images.read("./block.png");
|
||||
var superMario = images.read('./super_mario.jpg');
|
||||
var block = images.read('./block.png');
|
||||
|
||||
var result = images.matchTemplate(superMario, block, {
|
||||
threshold: 0.8
|
||||
threshold: 0.8,
|
||||
}).matches;
|
||||
toastLog(result);
|
||||
|
||||
superMario.recycle();
|
||||
block.recycle();
|
||||
block.recycle();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
var superMario = images.read("./super_mario.jpg");
|
||||
var mario = images.read("./mario.png");
|
||||
var superMario = images.read('./super_mario.jpg');
|
||||
var mario = images.read('./mario.png');
|
||||
var point = findImage(superMario, mario);
|
||||
toastLog(point);
|
||||
|
||||
superMario.recycle();
|
||||
mario.recycle();
|
||||
mario.recycle();
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0x9966ff为编辑器紫色字体的颜色
|
||||
toastLog("开始找色");
|
||||
// 0x9966ff 为编辑器紫色字体的颜色
|
||||
toastLog('开始找色');
|
||||
var point = findColor(img, 0x9966ff);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
if (point) {
|
||||
toastLog('x = ' + point.x + ', y = ' + point.y);
|
||||
} else {
|
||||
toastLog('没有找到');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
//0x1d75b3为编辑器默认主题蓝色字体(if, var等关键字)的颜色
|
||||
//找到颜色与0x1d75b3完全相等的颜色
|
||||
toastLog('开始找色');
|
||||
// 0x1d75b3 为编辑器默认主题蓝色字体 (if, var 等关键字) 的颜色
|
||||
// 找到颜色与 0x1d75b3 完全相等的颜色
|
||||
var point = findColorEquals(img, 0x006699);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
if (point) {
|
||||
toastLog('x = ' + point.x + ', y = ' + point.y);
|
||||
} else {
|
||||
toastLog('没有找到');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//这个是Auto.js图标的地址
|
||||
var url = "https://www.autojs.org/assets/uploads/profile/3-profileavatar.png";
|
||||
// 这个是 Auto.js 图标的地址
|
||||
var url = 'https://www.autojs.org/assets/uploads/profile/3-profileavatar.png';
|
||||
var logo = images.load(url);
|
||||
//保存到路径/sdcard/auto.js.png
|
||||
images.save(logo, "/sdcard/auto.js.png");
|
||||
// 保存到路径 /sdcard/auto.js.png
|
||||
images.save(logo, '/sdcard/auto.js.png');
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
exit
|
||||
if (!requestScreenCapture()) {
|
||||
toast('请求截图失败');
|
||||
exit;
|
||||
}
|
||||
sleep(2000);
|
||||
var x = 760;
|
||||
var y = 180;
|
||||
//获取在点(x, y)处的颜色
|
||||
// 获取在点 (x, y) 处的颜色
|
||||
var c = images.pixel(captureScreen(), x, y);
|
||||
//显示该颜色
|
||||
var msg = "";
|
||||
msg += "在位置(" + x + ", " + y + ")处的颜色为" + colors.toString(c);
|
||||
msg += "\nR = " + colors.red(c) + ", G = " + colors.green(c) + ", B = " + colors.blue(c);
|
||||
//检测在点(x, y)处是否有颜色#73bdb6 (模糊比较)
|
||||
var isDetected = images.detectsColor(captureScreen(), "#73bdb6", x, y);
|
||||
msg += "\n该位置是否匹配到颜色#73bdb6: " + isDetected;
|
||||
alert(msg);
|
||||
// 显示该颜色
|
||||
var msg = '';
|
||||
msg += '在位置 (' + x + ', ' + y + ') 处的颜色为 ' + colors.toString(c);
|
||||
msg += '\nR = ' + colors.red(c) + ', G = ' + colors.green(c) + ', B = ' + colors.blue(c);
|
||||
// 检测在点 (x, y) 处是否有颜色 #73bdb6 (模糊比较)
|
||||
var isDetected = images.detectsColor(captureScreen(), '#73bdb6', x, y);
|
||||
msg += '\n该位置是否匹配到颜色 #73bdb6: ' + isDetected;
|
||||
alert(msg);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var running = true;
|
||||
|
||||
threads.start(function(){
|
||||
while(running){
|
||||
log("running = true");
|
||||
threads.start(function () {
|
||||
while (running) {
|
||||
log('running = true');
|
||||
}
|
||||
});
|
||||
|
||||
sleep(2000);
|
||||
running = false;
|
||||
console.info("running = false");
|
||||
console.info('running = false');
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
auto();
|
||||
|
||||
threads.start(function(){
|
||||
//在子线程中调用observeKey()从而使按键事件处理在子线程执行
|
||||
threads.start(function () {
|
||||
// 在子线程中调用 observeKey() 从而使按键事件处理在子线程执行
|
||||
events.observeKey();
|
||||
events.on("key_down", function(keyCode, events){
|
||||
//音量键关闭脚本
|
||||
if(keyCode === keys.volume_up){
|
||||
events.on('key_down', function (keyCode, events) {
|
||||
// 音量键关闭脚本
|
||||
if (keyCode === keys.volume_up) {
|
||||
exit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
toast("音量上键关闭脚本");
|
||||
toast('音量上键关闭脚本');
|
||||
|
||||
events.on("exit", function(){
|
||||
toast("脚本已结束");
|
||||
events.on('exit', function () {
|
||||
toast('脚本已结束');
|
||||
});
|
||||
|
||||
while(true){
|
||||
log("脚本运行中...");
|
||||
while (true) {
|
||||
log('脚本运行中...');
|
||||
sleep(2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
|
||||
//启动一个线程
|
||||
threads.start(function(){
|
||||
//在线程中每隔1秒打印"线程1"
|
||||
while(true){
|
||||
log("线程1");
|
||||
// 启动一个线程
|
||||
threads.start(function () {
|
||||
// 在线程中每隔 1 秒打印"线程 1"
|
||||
while (true) {
|
||||
log('线程 1');
|
||||
sleep(1000);
|
||||
}
|
||||
});
|
||||
|
||||
//启动另一个线程
|
||||
threads.start(function(){
|
||||
//在线程中每隔2秒打印"线程1"
|
||||
while(true){
|
||||
log("线程2");
|
||||
// 启动另一个线程
|
||||
threads.start(function () {
|
||||
// 在线程中每隔 2 秒打印"线程 1"
|
||||
while (true) {
|
||||
log('线程 2');
|
||||
sleep(2000);
|
||||
}
|
||||
});
|
||||
|
||||
//在主线程中每隔3秒打印"主线程"
|
||||
for(var i = 0; i < 10; i++){
|
||||
log("主线程");
|
||||
// 在主线程中每隔 3 秒打印"主线程"
|
||||
for (var i = 0; i < 10; i++) {
|
||||
log('主线程');
|
||||
sleep(3000);
|
||||
}
|
||||
//打印100次后退出所有线程
|
||||
// 打印 100 次后退出所有线程
|
||||
threads.shutDownAll();
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
|
||||
//启动一个无限循环的线程
|
||||
var thread = threads.start(function(){
|
||||
while(true){
|
||||
log("子线程运行中...");
|
||||
// 启动一个无限循环的线程
|
||||
var thread = threads.start(function () {
|
||||
while (true) {
|
||||
log('子线程运行中...');
|
||||
sleep(1000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//5秒后关闭线程
|
||||
// 5 秒后关闭线程
|
||||
sleep(5000);
|
||||
thread.interrupt();
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
toast("静等20秒,你会看到想看的...");
|
||||
toast('静等 20 秒, 你会看到想看的...');
|
||||
|
||||
var i = 0;
|
||||
|
||||
setTimeout(function(){
|
||||
app.openUrl("http://music.163.com/#/song?id=109628&autoplay=true&market=baiduhd");
|
||||
setTimeout(function () {
|
||||
app.openUrl('http://music.163.com/#/song?id=109628&autoplay=true&market=baiduhd');
|
||||
exit();
|
||||
}, 20 * 1000);
|
||||
|
||||
setInterval(function(){
|
||||
setInterval(function () {
|
||||
i++;
|
||||
toast(i * 5 + "秒");
|
||||
toast(i * 5 + ' 秒');
|
||||
}, 5000);
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
var i = 0;
|
||||
|
||||
setInterval(function(){
|
||||
setInterval(function () {
|
||||
i++;
|
||||
toast(i * 4 + "秒");
|
||||
if(i === 5){
|
||||
toast(i * 4 + ' 秒');
|
||||
if (i === 5) {
|
||||
exit();
|
||||
}
|
||||
}, 4000);
|
||||
|
||||
|
||||
@@ -45,4 +45,4 @@ timers.setIntervalExt(config.listener, config.interval, config.condition, config
|
||||
// config.listener();
|
||||
// } while (!(result = config.condition()));
|
||||
//
|
||||
// config.callback(result);
|
||||
// config.callback(result);
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical>
|
||||
<button id="callback" align="center">回调形式</button>
|
||||
<button id="promise" align="center">Promise形式</button>
|
||||
<button id="promise" align="center">Promise 形式</button>
|
||||
<button id="calc" align="center">简单计算器</button>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.callback.click(()=>{
|
||||
dialogs.confirm("要弹出输入框吗?", "", function(b){
|
||||
if(b){
|
||||
dialogs.rawInput("输入", "", function(str){
|
||||
alert("您输入的是:" + str);
|
||||
ui.callback.click(() => {
|
||||
dialogs.confirm('要弹出输入框吗?', '', function (b) {
|
||||
if (b) {
|
||||
dialogs.rawInput('输入', '', function (str) {
|
||||
alert('您输入的是:' + str);
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
ui.finish();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.promise.click(()=>{
|
||||
dialogs.confirm("要弹出输入框吗")
|
||||
.then(function(b){
|
||||
if(b){
|
||||
return dialogs.rawInput("输入");
|
||||
}else{
|
||||
ui.promise.click(() => {
|
||||
dialogs.confirm('要弹出输入框吗')
|
||||
.then(function (b) {
|
||||
if (b) {
|
||||
return dialogs.rawInput('输入');
|
||||
} else {
|
||||
ui.finish();
|
||||
}
|
||||
}).then(function(str){
|
||||
alert("您输入的是:" + str);
|
||||
});
|
||||
}).then(function (str) {
|
||||
alert('您输入的是:' + str);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
ui.calc.click(()=>{
|
||||
ui.calc.click(() => {
|
||||
let num1, num2, op;
|
||||
dialogs.input("请输入第一个数字")
|
||||
dialogs.input('请输入第一个数字')
|
||||
.then(n => {
|
||||
num1 = n;
|
||||
return dialogs.singleChoice("请选择运算", ["加", "减", "乘", "除", "幂"]);
|
||||
return dialogs.singleChoice('请选择运算', [ '加', '减', '乘', '除', '幂' ]);
|
||||
})
|
||||
.then(o => {
|
||||
op = o;
|
||||
return dialogs.input("请输入第二个数字");
|
||||
})
|
||||
return dialogs.input('请输入第二个数字');
|
||||
})
|
||||
.then(n => {
|
||||
num2 = n;
|
||||
var result;
|
||||
switch(op){
|
||||
switch (op) {
|
||||
case 0:
|
||||
result = num1 + num2;
|
||||
break;
|
||||
@@ -65,6 +65,6 @@ ui.calc.click(()=>{
|
||||
result = Math.pow(num1, num2);
|
||||
break;
|
||||
}
|
||||
alert("运算结果", result);
|
||||
alert('运算结果', result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,4 +60,4 @@ setInterval(() => {
|
||||
cachedTimeStr = timeStr;
|
||||
dialog.setContent(`${timeStr}\n${urlStr}`);
|
||||
}
|
||||
}, 30);
|
||||
}, 30);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var sex = dialogs.singleChoice("请选择性别", ["男", "女", "基佬", "女装", "其他"], 2);
|
||||
toast("选择了第" + (sex + 1) + "个选项");
|
||||
var sex = dialogs.singleChoice('请选择性别', [ '男', '女', '基佬', '女装', '其他' ], 2);
|
||||
toast('选择了第' + (sex + 1) + '个选项');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var i = dialogs.multiChoice("下列作品出自李贽的是", ["《焚书》", "《西湖寻梦》", "《高太史全集》", "《续焚烧书》", "《藏书》"]);
|
||||
toast("选择了: " + i);
|
||||
if(i.length === 2 && i.toString() === [0, 4].toString()){
|
||||
toast("答对辣");
|
||||
}else{
|
||||
toast("答错辣");
|
||||
}
|
||||
var i = dialogs.multiChoice('下列作品出自李贽的是', [ '<<焚书>>', '<<西湖寻梦>>', '<<高太史全集>>', '<<续焚烧书>>', '<<藏书>>' ]);
|
||||
toast('选择了: ' + i);
|
||||
if (i.length === 2 && i.toString() === [ 0, 4 ].toString()) {
|
||||
toast('答对辣');
|
||||
} else {
|
||||
toast('答错辣');
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
var releaseNotes = "版本 v7.7.7\n"
|
||||
+ "更新日志:\n"
|
||||
+ "* 新增 若干Bug\n";
|
||||
var releaseNotes = '版本 v7.7.7\n'
|
||||
+ '更新日志:\n'
|
||||
+ '* 新增 若干 Bug\n';
|
||||
dialogs.build({
|
||||
title: "发现新版本",
|
||||
title: '发现新版本',
|
||||
content: releaseNotes,
|
||||
positive: "立即下载",
|
||||
negative: "取消",
|
||||
neutral: "到浏览器下载"
|
||||
positive: '立即下载',
|
||||
negative: '取消',
|
||||
neutral: '到浏览器下载',
|
||||
})
|
||||
.on("positive", download)
|
||||
.on("neutral", () => {
|
||||
app.openUrl("https://www.autojs.org");
|
||||
.on('positive', download)
|
||||
.on('neutral', () => {
|
||||
app.openUrl('https://www.autojs.org');
|
||||
})
|
||||
.show();
|
||||
|
||||
var downloadDialog = null;
|
||||
var downloadId = -1;
|
||||
|
||||
function download(){
|
||||
function download() {
|
||||
downloadDialog = dialogs.build({
|
||||
title: "下载中...",
|
||||
positive: "暂停",
|
||||
negative: "取消",
|
||||
title: '下载中...',
|
||||
positive: '暂停',
|
||||
negative: '取消',
|
||||
progress: {
|
||||
max: 100,
|
||||
showMinMax: true
|
||||
showMinMax: true,
|
||||
},
|
||||
autoDismiss: false
|
||||
autoDismiss: false,
|
||||
})
|
||||
.on("positive", ()=>{
|
||||
if(downloadDialog.getActionButton("positive") === "暂停"){
|
||||
.on('positive', () => {
|
||||
if (downloadDialog.getActionButton('positive') === '暂停') {
|
||||
stopDownload();
|
||||
downloadDialog.setActionButton("positive", "继续");
|
||||
}else{
|
||||
downloadDialog.setActionButton('positive', '继续');
|
||||
} else {
|
||||
startDownload();
|
||||
downloadDialog.setActionButton("positive", "暂停");
|
||||
downloadDialog.setActionButton('positive', '暂停');
|
||||
}
|
||||
})
|
||||
.on("negative", ()=>{
|
||||
.on('negative', () => {
|
||||
stopDownload();
|
||||
downloadDialog.dismiss();
|
||||
downloadDialog = null;
|
||||
@@ -46,21 +46,20 @@ function download(){
|
||||
startDownload();
|
||||
}
|
||||
|
||||
function startDownload(){
|
||||
downloadId = setInterval(()=>{
|
||||
function startDownload() {
|
||||
downloadId = setInterval(() => {
|
||||
var p = downloadDialog.getProgress();
|
||||
if(p >= 100){
|
||||
if (p >= 100) {
|
||||
stopDownload();
|
||||
downloadDialog.dismiss();
|
||||
downloadDialog = null;
|
||||
toast("下载完成");
|
||||
}else{
|
||||
toast('下载完成');
|
||||
} else {
|
||||
downloadDialog.setProgress(p + 1);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function stopDownload(){
|
||||
function stopDownload() {
|
||||
clearInterval(downloadId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
var handsome = confirm("你帅吗?");
|
||||
if(handsome){
|
||||
toast("真不要脸!");
|
||||
toast("真不要脸!");
|
||||
toast("真不要脸!");
|
||||
alert("真不要脸!");
|
||||
}else{
|
||||
toast("嗯");
|
||||
}
|
||||
var handsome = confirm('你帅吗?');
|
||||
if (handsome) {
|
||||
toast('真不要脸!');
|
||||
toast('真不要脸!');
|
||||
toast('真不要脸!');
|
||||
alert('真不要脸!');
|
||||
} else {
|
||||
toast('嗯');
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
while(true){
|
||||
var i = dialogs.select("哲学的基本问题是", "社会和自然的关系问题", "思维与存在的关系问题", "政治和经济的关系问题", "实践和理论的关系问题");
|
||||
if(i === -1){
|
||||
toast("猜一下呗");
|
||||
while (true) {
|
||||
var i = dialogs.select('哲学的基本问题是', '社会和自然的关系问题', '思维与存在的关系问题', '政治和经济的关系问题', '实践和理论的关系问题');
|
||||
if (i === -1) {
|
||||
toast('猜一下呗');
|
||||
continue;
|
||||
}
|
||||
if(i === 1){
|
||||
toast("答对辣");
|
||||
if (i === 1) {
|
||||
toast('答对辣');
|
||||
break;
|
||||
}else{
|
||||
toast("答错辣")
|
||||
} else {
|
||||
toast('答错辣');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var name = rawInput("请输入名字");
|
||||
alert("(•́へ•́╬)", "你好~ " + name);
|
||||
var expr = dialogs.input("请输入简单的算式", "1+1");
|
||||
alert("计算结果为 " + expr);
|
||||
var name = rawInput('请输入名字');
|
||||
alert('(•́へ•́╬)', '你好~ ' + name);
|
||||
var expr = dialogs.input('请输入简单的算式', '1+1');
|
||||
alert('计算结果: ' + expr);
|
||||
|
||||
@@ -11,12 +11,12 @@ let _ = {
|
||||
textSize: 16,
|
||||
inputHint: '输入要检索的内容',
|
||||
sampleTitle: '检索示例',
|
||||
samples: ['30', 'R', 'Android 11', 'oreo', 'pie', 'cookie', 'nougat', 'jelly bean',
|
||||
samples: [ '30', 'R', 'Android 11', 'oreo', 'pie', 'cookie', 'nougat', 'jelly bean',
|
||||
'7.1.1', '7.1', '8.0', '8', '2022', '2022 Mar', '2022 March', '2022 3', '2022/3',
|
||||
'2022/03', 'Mar 2022', 'March 2022', 'Mar, 2022', 'March, 2022', '2022 Mar 07',
|
||||
'2022 Mar 7', '2022 March 7', '2022 3 7', '2022/3/7', '2022/3/07', '2022/03/07',
|
||||
'Mar 7 2022', 'March 7 2022', 'Mar 7, 2022', 'March 7, 2022'],
|
||||
infoKeys: ['versionCode', 'apiLevel', 'platformVersion', 'releaseName', 'internalCodename', 'releaseDate'],
|
||||
'Mar 7 2022', 'March 7 2022', 'Mar 7, 2022', 'March 7, 2022' ],
|
||||
infoKeys: [ 'versionCode', 'apiLevel', 'platformVersion', 'releaseName', 'internalCodename', 'releaseDate' ],
|
||||
};
|
||||
|
||||
let $ = {
|
||||
@@ -101,4 +101,4 @@ let $ = {
|
||||
},
|
||||
};
|
||||
|
||||
$.show();
|
||||
$.show();
|
||||
|
||||
@@ -21,4 +21,4 @@ console.log(`pattern: ${morse.pattern}`);
|
||||
|
||||
// morse.vibrate();
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -23,4 +23,4 @@ test(new java.lang.Integer(0.5).getClass() === java.lang.Integer);
|
||||
test(util.getClass(new java.lang.Integer(0.5)) === java.lang.Integer);
|
||||
test(util.getClass(new java.lang.Integer(0.5)) === util.getClass(java.lang.Integer));
|
||||
|
||||
console.launch();
|
||||
console.launch();
|
||||
|
||||
@@ -90,4 +90,4 @@ ui.emitter.on('activity_result', (requestCode, resultCode, data) => {
|
||||
}
|
||||
fileChooserResolve = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
/**
|
||||
* By Da Zhang
|
||||
* 本脚本仅为娱乐,没有任何破坏性质
|
||||
* 本脚本仅为娱乐, 没有任何破坏性质
|
||||
*/
|
||||
|
||||
ui.statusBarColor("#AA0000");
|
||||
ui.statusBarColor('#AA0000');
|
||||
|
||||
var Quin = 32552732;
|
||||
|
||||
ui.layout(
|
||||
<frame background="#AA0000">
|
||||
<vertical align="top" paddingTop="5" margin="10">
|
||||
<text id="oops" color="#FFFFFF" gravity="center" size="20">Oops, your files have been encrypted!</text>
|
||||
<text id="text" bg="#FFFFFF" gravity="left" color="#000000" size="15" marginTop="15" h="425"></text>
|
||||
<button id="payment" text="Payment" margin="20 0 0 0"/>
|
||||
<button id="decrypt" text="Decrypt"/>
|
||||
</vertical>
|
||||
</frame>
|
||||
<vertical align="top" paddingTop="5" margin="10">
|
||||
<text id="oops" color="#FFFFFF" gravity="center" size="20">Oops, your files have been encrypted!</text>
|
||||
<text id="text" bg="#FFFFFF" gravity="left" color="#000000" size="15" marginTop="15" h="425"></text>
|
||||
<button id="payment" text="Payment" margin="20 0 0 0"/>
|
||||
<button id="decrypt" text="Decrypt"/>
|
||||
</vertical>
|
||||
</frame>,
|
||||
);
|
||||
ui.text.text("我的手机出了什么问题?\n您的一些重要文件被我加密保存了。\n" +
|
||||
"照片、图片、文档、压缩包、音频、视频文件、apk文件等,几乎所有类型的文件都被加密了,因此不能正常打开。\n" +
|
||||
"这和一般文件损坏有本质上的区别。您大可在网上找找恢复文件的方法,我敢保证,没有我们的解密服务,就算老天爷来了也不能恢复这些文档。\n\n" +
|
||||
"有没有恢复这些文档的方法?\n当然有可恢复的方法。只能通过我们的解密服务才能恢复。我以人格担保,能够提供安全有效的恢复服务。\n" +
|
||||
"但这是收费的,也不能无限期的推迟。\n请点击 <Decrypt> 按钮,就可以免费恢复一些文档。请您放心,我是绝不会骗你的。\n" +
|
||||
"但想要恢复全部文档,需要付款点费用。\n是否随时都可以固定金额付款,就会恢复的吗,当然不是,推迟付款时间越长,对你不利。\n" +
|
||||
"最好3天之内付款费用,过了三天费用就会翻倍。\n还有,一个礼拜之内未付款,将会永远恢复不了。\n" +
|
||||
"对了,忘了告诉你,对半年以上没钱付款的穷人,会有活动免费恢复,能否轮到你,就要看您的运气怎么样了。");
|
||||
ui.oops.click(() => toast("Fuck you!"));
|
||||
ui.text.text('我的手机出了什么问题?\n 您的一些重要文件被我加密保存了.\n' +
|
||||
'照片/图片/文档/压缩包/音频/视频文件/apk 文件等, 几乎所有类型的文件都被加密了, 因此不能正常打开.\n' +
|
||||
'这和一般文件损坏有本质上的区别. 您大可在网上找找恢复文件的方法, 我敢保证, 没有我们的解密服务, 就算老天爷来了也不能恢复这些文档.\n\n' +
|
||||
'有没有恢复这些文档的方法?\n 当然有可恢复的方法. 只能通过我们的解密服务才能恢复. 我以人格担保, 能够提供安全有效的恢复服务.\n' +
|
||||
'但这是收费的, 也不能无限期的推迟.\n 请点击 <Decrypt> 按钮, 就可以免费恢复一些文档. 请您放心, 我是绝不会骗你的.\n' +
|
||||
'但想要恢复全部文档, 需要付款点费用.\n 是否随时都可以固定金额付款, 就会恢复的吗, 当然不是, 推迟付款时间越长, 对你不利.\n' +
|
||||
'最好 3 天之内付款费用, 过了三天费用就会翻倍.\n 还有, 一个礼拜之内未付款, 将会永远恢复不了.\n' +
|
||||
'对了, 忘了告诉你, 对半年以上没钱付款的穷人, 会有活动免费恢复, 能否轮到你, 就要看您的运气怎么样了.');
|
||||
ui.oops.click(() => toast('Fuck you!'));
|
||||
ui.oops.longClick(() => {
|
||||
var thisjoke="This is a joke : )";
|
||||
if(ui.oops.text() !== thisjoke){
|
||||
ui.oops.text(thisjoke);
|
||||
}else{
|
||||
ui.oops.text("Oops, your files have been encrypted!");
|
||||
var thisjoke = 'This is a joke :)';
|
||||
if (ui.oops.text() !== thisjoke) {
|
||||
ui.oops.text(thisjoke);
|
||||
} else {
|
||||
ui.oops.text('Oops, your files have been encrypted!');
|
||||
}
|
||||
return true;
|
||||
});
|
||||
ui.text.click(() => ui.text.append("。"));
|
||||
ui.text.click(() => ui.text.append('.'));
|
||||
ui.text.longClick(() => {
|
||||
ui.text.setText("\n"+ui.text.getText())
|
||||
ui.text.setText('\n' + ui.text.getText());
|
||||
return true;
|
||||
});
|
||||
ui.payment.click(() => {
|
||||
try{
|
||||
app.startActivity({
|
||||
action:"android.intent.action.VIEW",
|
||||
data:"mqqapi://card/show_pslcard?&uin=" + Quin
|
||||
});
|
||||
toast("Please payment by QQ");
|
||||
}catch(e){
|
||||
toast("Payment Error");
|
||||
}
|
||||
try {
|
||||
app.startActivity({
|
||||
action: 'android.intent.action.VIEW',
|
||||
data: 'mqqapi://card/show_pslcard?&uin=' + Quin,
|
||||
});
|
||||
toast('Please payment by QQ');
|
||||
} catch (e) {
|
||||
toast('Payment Error');
|
||||
}
|
||||
});
|
||||
ui.payment.longClick(() => {
|
||||
toast("You are silly b!");
|
||||
return true;
|
||||
toast('You are silly b!');
|
||||
return true;
|
||||
});
|
||||
ui.decrypt.click(() => {
|
||||
toast("Decrypt Error");
|
||||
activity.finish();
|
||||
toast('Decrypt Error');
|
||||
activity.finish();
|
||||
});
|
||||
ui.decrypt.longClick(() => {
|
||||
toast("You cannot decrypt!");
|
||||
return true;
|
||||
toast('You cannot decrypt!');
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -7,4 +7,4 @@ window.onload = function () {
|
||||
document.getElementById('testButton').addEventListener('click', () => {
|
||||
$autojs.invoke('toast-log', '按钮已被点击');
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -10,4 +10,4 @@ let web = ui['web'];
|
||||
|
||||
web.jsBridge.handle('toast-log', (event, msg) => {
|
||||
toastLog(msg);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ let iconMap = {};
|
||||
ui.apps.setDataSource(appList);
|
||||
|
||||
ui.apps.on('item_click', item => {
|
||||
new com.afollestad.materialdialogs.MaterialDialog.Builder(context).limitIconToDefaultSize()
|
||||
new com.afollestad.materialdialogs.MaterialDialog.Builder(context).limitIconToDefaultSize();
|
||||
dialogs.build({
|
||||
title: '应用信息',
|
||||
icon: item.icon,
|
||||
@@ -81,4 +81,4 @@ function listApps(appList) {
|
||||
});
|
||||
iconMap[p.packageName] = icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ ui.todoList.on('item_long_click', function (e, item, i, itemView, listView) {
|
||||
e.consumed = true;
|
||||
});
|
||||
|
||||
//当离开本界面时保存todoList
|
||||
// 当离开本界面时保存todoList
|
||||
ui.emitter.on('pause', () => {
|
||||
storage.put('items', todoList);
|
||||
});
|
||||
@@ -119,4 +119,4 @@ ui.add.on('click', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,30 +32,30 @@ ui.layout(
|
||||
<frame>
|
||||
<vertical>
|
||||
<appbar>
|
||||
<toolbar id="toolbar" title="TODO" />
|
||||
<toolbar id="toolbar" title="TODO"/>
|
||||
</appbar>
|
||||
<button id="selectAll" text="全部完成" isColored margin="6 4" />
|
||||
<button id="selectAll" text="全部完成" isColored margin="6 4"/>
|
||||
<list id="todoList">
|
||||
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
|
||||
cardElevation="1dp" foreground="?selectableItemBackground">
|
||||
<horizontal gravity="center_vertical">
|
||||
<view bg="{{this.color}}" h="*" w="10" />
|
||||
<view bg="{{this.color}}" h="*" w="10"/>
|
||||
<vertical padding="10 8" h="auto" w="0" layout_weight="1">
|
||||
<text id="title" text="{{this.title}}" textColor="blue-grey-900" textSize="16sp" maxLines="1" paddingBottom="4dp" />
|
||||
<text text="{{this.summary}}" textColor="blue-grey-300" textSize="14sp" maxLines="1" />
|
||||
<text id="title" text="{{this.title}}" textColor="blue-grey-900" textSize="16sp" maxLines="1" paddingBottom="4dp"/>
|
||||
<text text="{{this.summary}}" textColor="blue-grey-300" textSize="14sp" maxLines="1"/>
|
||||
</vertical>
|
||||
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" tint="blue-grey-500,pink-300" />
|
||||
<checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" tint="blue-grey-500,pink-300"/>
|
||||
</horizontal>
|
||||
</card>
|
||||
</list>
|
||||
</vertical>
|
||||
<fab id="add" w="auto" h="auto" src="@drawable/ic_add_black_48dp"
|
||||
margin="16" layout_gravity="bottom|right" tint="white" backgroundTint="orange-800" />
|
||||
margin="16" layout_gravity="bottom|right" tint="white" backgroundTint="orange-800"/>
|
||||
</frame>,
|
||||
);
|
||||
|
||||
// 从 storage 获取待办事项列表
|
||||
let todoList = storage.get('items', [{
|
||||
let todoList = storage.get('items', [ {
|
||||
title: '写操作系统作业',
|
||||
summary: '明天第 1 - 2 节',
|
||||
color: 'red-500',
|
||||
@@ -75,7 +75,7 @@ let todoList = storage.get('items', [{
|
||||
summary: '2031 年 5 月',
|
||||
color: '#2196f3',
|
||||
done: false,
|
||||
}]);
|
||||
} ]);
|
||||
|
||||
ui.statusBarColor(themeColor);
|
||||
ui['toolbar'].attr('bg', themeColor);
|
||||
@@ -139,4 +139,4 @@ ui['add'].on('click', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,4 +13,4 @@ let btnView = ui['btn'];
|
||||
/** @type {JsViewSwitcher} */
|
||||
let viewSwitcher = ui['vs'];
|
||||
|
||||
btnView.on('click', () => viewSwitcher.showNext());
|
||||
btnView.on('click', () => viewSwitcher.showNext());
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
ui.layout(<vertical>
|
||||
<video id="video" src="@raw/text_tool" controller></video>
|
||||
<button id="video_btn" text="play" isColored bg="teal-600" />
|
||||
<button id="video_btn" text="play" isColored bg="teal-600"/>
|
||||
</vertical>);
|
||||
|
||||
/** @type {JsButton} */
|
||||
@@ -40,4 +40,4 @@ function setStatePaused() {
|
||||
function setStatePlaying() {
|
||||
videoBtnView.attr('text', 'pause');
|
||||
videoBtnView.attr('bg', 'blue-800');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical>
|
||||
<text textSize="18sp" textColor="#000000" margin="20" textStyle="bold">
|
||||
关于Auto.js的用户调查
|
||||
关于 Auto.js 的用户调查
|
||||
</text>
|
||||
<ScrollView>
|
||||
<vertical>
|
||||
<text textSize="16sp" margin="8">1. 您的年龄是?</text>
|
||||
<input text="18" inputType="number" margin="0 16"/>
|
||||
<text textSize="16sp" margin="8">2. 您用过其他类似软件(脚本精灵,按键精灵等)吗?</text>
|
||||
<text textSize="16sp" margin="8">2. 您用过其他类似软件 (脚本精灵, 按键精灵等) 吗?</text>
|
||||
<radiogroup margin="0 16">
|
||||
<radio text="没有用过"/>
|
||||
<radio text="用过"/>
|
||||
<radio text="用过,感觉不好用"/>
|
||||
<radio text="没有Root权限无法使用"/>
|
||||
<radio text="用过, 感觉不好用"/>
|
||||
<radio text="没有 Root 权限无法使用"/>
|
||||
</radiogroup>
|
||||
<text textSize="16sp" margin="8">3. 您使用Auto.js通常用于做什么?(多选)</text>
|
||||
<text textSize="16sp" margin="8">3. 您使用 Auto.js 通常用于做什么? (多选)</text>
|
||||
<checkbox text="游戏辅助" marginLeft="16"/>
|
||||
<checkbox text="点赞" marginLeft="16"/>
|
||||
<checkbox text="日常生活工作辅助" marginLeft="16"/>
|
||||
@@ -33,14 +33,14 @@ ui.layout(
|
||||
<radio/>
|
||||
<img w="100" h="100" margin="0 16" src="http://www.autojs.org/assets/uploads/files/1511945512596-autojs_logo.png"/>
|
||||
</radiogroup>
|
||||
<text textSize="16sp" margin="8">5. 您是什么时候开始使用Auto.js的呢?</text>
|
||||
<text textSize="16sp" margin="8">5. 您是什么时候开始使用 Auto.js 的呢?</text>
|
||||
<datepicker margin="4 16" datePickerMode="spinner"/>
|
||||
<text textSize="16sp" margin="8">6. 您用过下面这个Auto.js的论坛吗?</text>
|
||||
<text textSize="16sp" margin="8">6. 您用过下面这个 Auto.js 的论坛吗?</text>
|
||||
<webview id="webview" h="300" margin="0 16"/>
|
||||
<radiogroup marginLeft="16" marginTop="16">
|
||||
<radio text="没有用过"/>
|
||||
<radio text="用过"/>
|
||||
<radio text="用过,感觉不好用"/>
|
||||
<radio text="用过, 感觉不好用"/>
|
||||
</radiogroup>
|
||||
<linear gravity="center">
|
||||
<button margin="16">提交</button>
|
||||
@@ -48,7 +48,7 @@ ui.layout(
|
||||
</linear>
|
||||
</vertical>
|
||||
</ScrollView>
|
||||
</vertical>
|
||||
)
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.webview.loadUrl("http://www.autojs.org");
|
||||
ui.webview.loadUrl('http://www.autojs.org');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
var color = "#009688";
|
||||
var color = '#009688';
|
||||
|
||||
ui.layout(
|
||||
<drawer id="drawer">
|
||||
@@ -30,60 +30,60 @@ ui.layout(
|
||||
</horizontal>
|
||||
</list>
|
||||
</vertical>
|
||||
</drawer>
|
||||
</drawer>,
|
||||
);
|
||||
|
||||
|
||||
//创建选项菜单(右上角)
|
||||
ui.emitter.on("create_options_menu", menu=>{
|
||||
menu.add("设置");
|
||||
menu.add("关于");
|
||||
// 创建选项菜单 (右上角)
|
||||
ui.emitter.on('create_options_menu', menu => {
|
||||
menu.add('设置');
|
||||
menu.add('关于');
|
||||
});
|
||||
//监听选项菜单点击
|
||||
ui.emitter.on("options_item_selected", (e, item)=>{
|
||||
switch(item.getTitle()){
|
||||
case "设置":
|
||||
toast("还没有设置");
|
||||
// 监听选项菜单点击
|
||||
ui.emitter.on('options_item_selected', (e, item) => {
|
||||
switch (item.getTitle()) {
|
||||
case '设置':
|
||||
toast('还没有设置');
|
||||
break;
|
||||
case "关于":
|
||||
alert("关于", "Auto.js界面模板 v1.0.0");
|
||||
case '关于':
|
||||
alert('关于', 'Auto.js 界面模板 v1.0.0');
|
||||
break;
|
||||
}
|
||||
e.consumed = true;
|
||||
});
|
||||
activity.setSupportActionBar(ui.toolbar);
|
||||
|
||||
//设置滑动页面的标题
|
||||
ui.viewpager.setTitles(["标签一", "标签二", "标签三"]);
|
||||
//让滑动页面和标签栏联动
|
||||
// 设置滑动页面的标题
|
||||
ui.viewpager.setTitles([ '标签一', '标签二', '标签三' ]);
|
||||
// 让滑动页面和标签栏联动
|
||||
ui.tabs.setupWithViewPager(ui.viewpager);
|
||||
|
||||
//让工具栏左上角可以打开侧拉菜单
|
||||
// 让工具栏左上角可以打开侧拉菜单
|
||||
ui.toolbar.setupWithDrawer(ui.drawer);
|
||||
|
||||
ui.menu.setDataSource([
|
||||
{
|
||||
title: "选项一",
|
||||
icon: "@drawable/ic_android_black_48dp"
|
||||
},
|
||||
{
|
||||
title: "选项二",
|
||||
icon: "@drawable/ic_settings_black_48dp"
|
||||
},
|
||||
{
|
||||
title: "选项三",
|
||||
icon: "@drawable/ic_favorite_black_48dp"
|
||||
},
|
||||
{
|
||||
title: "退出",
|
||||
icon: "@drawable/ic_exit_to_app_black_48dp"
|
||||
}
|
||||
{
|
||||
title: '选项一',
|
||||
icon: '@drawable/ic_android_black_48dp',
|
||||
},
|
||||
{
|
||||
title: '选项二',
|
||||
icon: '@drawable/ic_settings_black_48dp',
|
||||
},
|
||||
{
|
||||
title: '选项三',
|
||||
icon: '@drawable/ic_favorite_black_48dp',
|
||||
},
|
||||
{
|
||||
title: '退出',
|
||||
icon: '@drawable/ic_exit_to_app_black_48dp',
|
||||
},
|
||||
]);
|
||||
|
||||
ui.menu.on("item_click", item => {
|
||||
switch(item.title){
|
||||
case "退出":
|
||||
ui.menu.on('item_click', item => {
|
||||
switch (item.title) {
|
||||
case '退出':
|
||||
ui.finish();
|
||||
break;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
showLoginUI();
|
||||
// ui.statusBarColor("#000000")
|
||||
|
||||
//显示登录界面
|
||||
function showLoginUI(){
|
||||
// 显示登录界面
|
||||
function showLoginUI() {
|
||||
ui.layout(
|
||||
<frame>
|
||||
<vertical h="auto" align="center" margin="0 50">
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">用户名</text>
|
||||
<input id="name" w="*" h="40"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
||||
<input id="password" w="*" h="40" password="true"/>
|
||||
</linear>
|
||||
<linear gravity="center">
|
||||
<button id="login" text="登录"/>
|
||||
<button id="register" text="注册"/>
|
||||
</linear>
|
||||
</vertical>
|
||||
</frame>
|
||||
<frame>
|
||||
<vertical h="auto" align="center" margin="0 50">
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">用户名</text>
|
||||
<input id="name" w="*" h="40"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
||||
<input id="password" w="*" h="40" password="true"/>
|
||||
</linear>
|
||||
<linear gravity="center">
|
||||
<button id="login" text="登录"/>
|
||||
<button id="register" text="注册"/>
|
||||
</linear>
|
||||
</vertical>
|
||||
</frame>,
|
||||
);
|
||||
|
||||
ui.login.on("click", () => {
|
||||
toast("您输入的用户名为" + ui.name.text() + " 密码为" + ui.password.text());
|
||||
ui.login.on('click', () => {
|
||||
toast('您输入的用户名: ' + ui.name.text() + ', 密码: ' + ui.password.text());
|
||||
});
|
||||
ui.register.on("click", () => showRegisterUI());
|
||||
ui.register.on('click', () => showRegisterUI());
|
||||
}
|
||||
|
||||
//显示注册界面
|
||||
function showRegisterUI(){
|
||||
// 显示注册界面
|
||||
function showRegisterUI() {
|
||||
ui.layout(
|
||||
<frame>
|
||||
<vertical h="auto" align="center" margin="0 50">
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">用户名</text>
|
||||
<input w="*" h="40"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
||||
<input w="*" h="40" password="true"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">邮箱</text>
|
||||
<input w="*" h="40" inputType="textEmailAddress"/>
|
||||
</linear>
|
||||
<linear gravity="center">
|
||||
<button>确定</button>
|
||||
<button id="cancel">取消</button>
|
||||
</linear>
|
||||
</vertical>
|
||||
</frame>
|
||||
<frame>
|
||||
<vertical h="auto" align="center" margin="0 50">
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">用户名</text>
|
||||
<input w="*" h="40"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">密码</text>
|
||||
<input w="*" h="40" password="true"/>
|
||||
</linear>
|
||||
<linear>
|
||||
<text w="56" gravity="center" color="#111111" size="16">邮箱</text>
|
||||
<input w="*" h="40" inputType="textEmailAddress"/>
|
||||
</linear>
|
||||
<linear gravity="center">
|
||||
<button>确定</button>
|
||||
<button id="cancel">取消</button>
|
||||
</linear>
|
||||
</vertical>
|
||||
</frame>,
|
||||
);
|
||||
ui.cancel.on("click", () => showLoginUI());
|
||||
}
|
||||
ui.cancel.on('click', () => showLoginUI());
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ ui.layout(
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:format24Hour="HH:mm"
|
||||
android:textSize="36sp" />,
|
||||
android:textSize="36sp"/>,
|
||||
);
|
||||
|
||||
/* 1 秒钟后应用自定义样式. */
|
||||
@@ -22,7 +22,9 @@ setTimeout(() => {
|
||||
ui.statusBarIconLightBy(themeColor);
|
||||
|
||||
ui.navigationBarColor(themeColor);
|
||||
ui.navigationBarIconLightBy(themeColor);
|
||||
if (util.version.sdkInt >= util.versionCodes.O) {
|
||||
ui.navigationBarIconLightBy(themeColor);
|
||||
}
|
||||
|
||||
/** @type {JsTextClock} */
|
||||
let textClockView = ui['text_clock'];
|
||||
|
||||
@@ -31,4 +31,4 @@ setTimeout(() => {
|
||||
textClockView.attr('size', '56');
|
||||
textClockView.attr('layout_gravity', 'center');
|
||||
textClockView.attr('format24Hour', 'HH:mm:ss');
|
||||
}, 1e3);
|
||||
}, 1e3);
|
||||
|
||||
@@ -7,4 +7,4 @@ if (!packageName) {
|
||||
toast(`应用 "${appName}" 不存在`);
|
||||
} else {
|
||||
app.uninstall(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
var i = dialogs.select("请选择工具", "获取应用包名", "打开应用详情页", "卸载应用");
|
||||
var i = dialogs.select('请选择工具', '获取应用包名', '打开应用详情页', '卸载应用');
|
||||
|
||||
if(i === -1){
|
||||
alert("没有选择任何工具!");
|
||||
if (i === -1) {
|
||||
alert('没有选择任何工具!');
|
||||
}
|
||||
|
||||
switch(i){
|
||||
case 0:
|
||||
//获取应用包名
|
||||
appName = rawInput("请输入应用名称", "QQ");
|
||||
packageName = getPackageName(appName);
|
||||
toast(packageName);
|
||||
setClip(packageName);
|
||||
toast("已复制到剪贴板");
|
||||
break;
|
||||
case 1:
|
||||
//打开应用详情页
|
||||
appName = rawInput("请输入应用名称", "微信");
|
||||
launchSettings(getPackageName(appName));
|
||||
break;
|
||||
case 2:
|
||||
//卸载应用
|
||||
appName = rawInput("请输入应用名称");
|
||||
packageName = getPackageName(appName);
|
||||
if(packageName === ""){
|
||||
toast("应用不存在");
|
||||
}else if(confirm("确定卸载应用" + packageName + "吗?")){
|
||||
app.uninstall(packageName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
// 获取应用包名
|
||||
appName = rawInput('请输入应用名称', 'QQ');
|
||||
packageName = getPackageName(appName);
|
||||
toast(packageName);
|
||||
setClip(packageName);
|
||||
toast('已复制到剪贴板');
|
||||
break;
|
||||
case 1:
|
||||
// 打开应用详情页
|
||||
appName = rawInput('请输入应用名称', '微信');
|
||||
launchSettings(getPackageName(appName));
|
||||
break;
|
||||
case 2:
|
||||
// 卸载应用
|
||||
appName = rawInput('请输入应用名称');
|
||||
packageName = getPackageName(appName);
|
||||
if (packageName === '') {
|
||||
toast('应用不存在');
|
||||
} else if (confirm('确定卸载应用 "' + packageName + '" 吗?')) {
|
||||
app.uninstall(packageName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"auto";
|
||||
'auto';
|
||||
|
||||
var appName = rawInput("请输入应用名称");
|
||||
var appName = rawInput('请输入应用名称');
|
||||
launchSettings(getPackageName(appName));
|
||||
while(!click("强制停止"));
|
||||
while (!click('强制停止')) ;
|
||||
|
||||
@@ -8,4 +8,4 @@ content && app.startActivity({
|
||||
extras: { 'android.intent.extra.TEXT': content },
|
||||
packageName: App.QQ.getPackageName(),
|
||||
className: '@{packageName}.activity.JumpActivity',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,4 +53,4 @@ App.ALIPAY.ensureInstalled();
|
||||
},
|
||||
},
|
||||
packageName: App.ALIPAY.getPackageName(),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,4 +20,4 @@ console.log(app.intentToShell({
|
||||
type: 'application/pics-rules',
|
||||
data: 'protocol://xxx',
|
||||
category: 'cat003',
|
||||
}).split(/ (?=-)/).join('\n'));
|
||||
}).split(/ (?=-)/).join('\n'));
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
var appName = rawInput("请输入应用名称");
|
||||
launchApp(appName);
|
||||
var appName = rawInput('请输入应用名称');
|
||||
launchApp(appName);
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
<horizontal>
|
||||
<text textSize="16sp">下拉菜单</text>
|
||||
<spinner id="sp1" entries="选项1|选项2|选项3"/>
|
||||
<spinner id="sp1" entries="选项 1|选项 2|选项 3"/>
|
||||
</horizontal>
|
||||
<horizontal>
|
||||
<text textSize="16sp">对话框菜单</text>
|
||||
<spinner id="sp2" entries="选项4|选项5|选项6" spinnerMode="dialog"/>
|
||||
<spinner id="sp2" entries="选项 4|选项 5|选项 6" spinnerMode="dialog"/>
|
||||
</horizontal>
|
||||
<button id="ok">确定</button>
|
||||
<button id="select3">选择选项3</button>
|
||||
</vertical>
|
||||
<button id="select3">选择选项 3</button>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.ok.on("click", ()=>{
|
||||
ui.ok.on('click', () => {
|
||||
var i = ui.sp1.getSelectedItemPosition();
|
||||
var j = ui.sp2.getSelectedItemPosition();
|
||||
toast("您的选择是选项" + (i + 1) + "和选项" + (j + 4));
|
||||
toast('您的选择是选项 ' + (i + 1) + ' 和选项 ' + (j + 4));
|
||||
});
|
||||
|
||||
ui.select3.on("click", ()=>{
|
||||
ui.select3.on('click', () => {
|
||||
ui.sp1.setSelection(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<frame>
|
||||
<list id="list">
|
||||
<vertical>
|
||||
<text id="name" textSize="16sp" textColor="#000000" text="姓名: {{name}}"/>
|
||||
<text id="age" textSize="16sp" textColor="#000000" text="年龄: {{age}}岁"/>
|
||||
<text id="age" textSize="16sp" textColor="#000000" text="年龄: {{age}} 岁"/>
|
||||
<button id="deleteItem" text="删除"/>
|
||||
</vertical>
|
||||
</list>
|
||||
</frame>
|
||||
</frame>,
|
||||
);
|
||||
|
||||
var items = [
|
||||
{name: "小明", age: 18}, {name: "小红", age: 30},
|
||||
{name: "小东", age: 19}, {name: "小强", age: 31},
|
||||
{name: "小满", age: 20}, {name: "小一", age: 32},
|
||||
{name: "小和", age: 21}, {name: "小二", age: 1},
|
||||
{name: "小贤", age: 22}, {name: "小三", age: 2},
|
||||
{name: "小伟", age: 23}, {name: "小四", age: 3},
|
||||
{name: "小黄", age: 24}, {name: "小五", age: 4},
|
||||
{name: "小健", age: 25}, {name: "小六", age: 5},
|
||||
{name: "小啦", age: 26}, {name: "小七", age: 6},
|
||||
{name: "小哈", age: 27}, {name: "小八", age: 7},
|
||||
{name: "小啊", age: 28}, {name: "小九", age: 8},
|
||||
{name: "小啪", age: 29}, {name: "小十", age: 9}
|
||||
{ name: '小明', age: 18 }, { name: '小红', age: 30 },
|
||||
{ name: '小东', age: 19 }, { name: '小强', age: 31 },
|
||||
{ name: '小满', age: 20 }, { name: '小一', age: 32 },
|
||||
{ name: '小和', age: 21 }, { name: '小二', age: 1 },
|
||||
{ name: '小贤', age: 22 }, { name: '小三', age: 2 },
|
||||
{ name: '小伟', age: 23 }, { name: '小四', age: 3 },
|
||||
{ name: '小黄', age: 24 }, { name: '小五', age: 4 },
|
||||
{ name: '小健', age: 25 }, { name: '小六', age: 5 },
|
||||
{ name: '小啦', age: 26 }, { name: '小七', age: 6 },
|
||||
{ name: '小哈', age: 27 }, { name: '小八', age: 7 },
|
||||
{ name: '小啊', age: 28 }, { name: '小九', age: 8 },
|
||||
{ name: '小啪', age: 29 }, { name: '小十', age: 9 },
|
||||
];
|
||||
|
||||
ui.list.setDataSource(items);
|
||||
|
||||
ui.list.on("item_click", function(item, i, itemView, listView){
|
||||
toast("被点击的人名字为: " + item.name + ",年龄为: " + item.age);
|
||||
ui.list.on('item_click', function (item, i, itemView, listView) {
|
||||
toast('被点击的人名字为: ' + item.name + ', 年龄为: ' + item.age);
|
||||
});
|
||||
|
||||
ui.list.on("item_bind", function(itemView, itemHolder){
|
||||
itemView.deleteItem.on("click", function(){
|
||||
ui.list.on('item_bind', function (itemView, itemHolder) {
|
||||
itemView.deleteItem.on('click', function () {
|
||||
let item = itemHolder.item;
|
||||
toast("被删除的人名字为: " + item.name + ",年龄为: " + item.age);
|
||||
toast('被删除的人名字为: ' + item.name + ', 年龄为: ' + item.age);
|
||||
items.splice(itemHolder.position, 1);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical>
|
||||
@@ -6,37 +6,36 @@ ui.layout(
|
||||
<toolbar id="toolbar" title="卡片布局"/>
|
||||
</appbar>
|
||||
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
<vertical padding="18 8" h="auto">
|
||||
<text text="写操作系统作业" textColor="#222222" textSize="16sp"/>
|
||||
<text text="明天第1~2节" textColor="#999999" textSize="14sp"/>
|
||||
<text text="明天第 1~2 节" textColor="#999999" textSize="14sp"/>
|
||||
</vertical>
|
||||
<View bg="#f44336" h="*" w="10"/>
|
||||
</card>
|
||||
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
<vertical padding="18 8" h="auto">
|
||||
<text text="修复ui模式的Bug" textColor="#222222" textSize="16sp"/>
|
||||
<text text="修复 ui 模式的 Bug" textColor="#222222" textSize="16sp"/>
|
||||
<text text="无限期" textColor="#999999" textSize="14sp"/>
|
||||
</vertical>
|
||||
<View bg="#ff5722" h="*" w="10"/>
|
||||
</card>
|
||||
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
<vertical padding="18 8" h="auto">
|
||||
<text text="发布Auto.js 10.0.0正式版" textColor="#222222" textSize="16sp"/>
|
||||
<text text="2019年1月" textColor="#999999" textSize="14sp"/>
|
||||
<text text="发布 Auto.js 10.0.0 正式版" textColor="#222222" textSize="16sp"/>
|
||||
<text text="2019 年 1 月" textColor="#999999" textSize="14sp"/>
|
||||
</vertical>
|
||||
<View bg="#4caf50" h="*" w="10"/>
|
||||
</card>
|
||||
<card w="*" h="70" margin="10 5" cardCornerRadius="2dp"
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
cardElevation="1dp" gravity="center_vertical">
|
||||
<vertical padding="18 8" h="auto">
|
||||
<text text="完成毕业设计和论文" textColor="#222222" textSize="16sp"/>
|
||||
<text text="2019年4月" textColor="#999999" textSize="14sp"/>
|
||||
<text text="2019 年 4 月" textColor="#999999" textSize="14sp"/>
|
||||
</vertical>
|
||||
<View bg="#2196f3" h="*" w="10"/>
|
||||
</card>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<scroll>
|
||||
<vertical bg="#707070" padding="16">
|
||||
<text text="网络图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/3-profileavatar.png"
|
||||
w="100" h="100"/>
|
||||
<scroll>
|
||||
<vertical bg="#707070" padding="16">
|
||||
<text text="网络图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/3-profileavatar.png"
|
||||
w="100" h="100"/>
|
||||
|
||||
<text text="带边框的图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" borderWidth="2dp" borderColor="#202020"/>
|
||||
<text text="带边框的图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" borderWidth="2dp" borderColor="#202020"/>
|
||||
|
||||
<text text="圆形图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" circle="true"/>
|
||||
<text text="圆形图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" circle="true"/>
|
||||
|
||||
<text text="带边框的圆形图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" circle="true" borderWidth="2dp" borderColor="#202020"/>
|
||||
<text text="带边框的圆形图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" circle="true" borderWidth="2dp" borderColor="#202020"/>
|
||||
|
||||
<text text="圆角图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img id="rounded_img" src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" radius="20dp" scaleType="fitXY"/>
|
||||
<button id="change_img" text="更改图片"/>
|
||||
</vertical>
|
||||
</scroll>
|
||||
<text text="圆角图片" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<img id="rounded_img" src="http://www.autojs.org/assets/uploads/profile/1-profileavatar.jpeg"
|
||||
w="100" h="100" radius="20dp" scaleType="fitXY"/>
|
||||
<button id="change_img" text="更改图片"/>
|
||||
</vertical>
|
||||
</scroll>,
|
||||
);
|
||||
|
||||
ui.change_img.on("click", ()=>{
|
||||
ui.rounded_img.setSource("http://www.autojs.org/assets/uploads/profile/1-profilecover.jpeg");
|
||||
});
|
||||
ui.change_img.on('click', () => {
|
||||
ui.rounded_img.setSource('http://www.autojs.org/assets/uploads/profile/1-profilecover.jpeg');
|
||||
});
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
<checkbox id="cb1" text="复选框"/>
|
||||
<checkbox id="cb2" checked="true" text="勾选的复选框"/>
|
||||
<radiogroup marginTop="16">
|
||||
<radio text="单选框1"/>
|
||||
<radio text="单选框2"/>
|
||||
<radio text="单选框3"/>
|
||||
<radio text="单选框 1"/>
|
||||
<radio text="单选框 2"/>
|
||||
<radio text="单选框 3"/>
|
||||
</radiogroup>
|
||||
<radiogroup marginTop="16">
|
||||
<radio text="单选框1"/>
|
||||
<radio text="单选框2"/>
|
||||
<radio text="勾选的单选框3" checked="true"/>
|
||||
<radio text="单选框 1"/>
|
||||
<radio text="单选框 2"/>
|
||||
<radio text="勾选的单选框 3" checked="true"/>
|
||||
</radiogroup>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.cb1.on("check", (checked)=>{
|
||||
if(checked){
|
||||
toast("第一个框被勾选了");
|
||||
}else{
|
||||
toast("第一个框被取消勾选了");
|
||||
ui.cb1.on('check', (checked) => {
|
||||
if (checked) {
|
||||
toast('第一个框被勾选了');
|
||||
} else {
|
||||
toast('第一个框被取消勾选了');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
@@ -8,13 +8,13 @@ ui.layout(
|
||||
<button text="无边框有颜色按钮" style="Widget.AppCompat.Button.Borderless.Colored" w="auto"/>
|
||||
<button text="长长的按钮" w="*"/>
|
||||
<button id="click_me" text="点我" w="auto"/>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.click_me.on("click", ()=>{
|
||||
toast("我被点啦");
|
||||
ui.click_me.on('click', () => {
|
||||
toast('我被点啦');
|
||||
});
|
||||
|
||||
ui.click_me.on("long_click", ()=>{
|
||||
toast("我被长按啦");
|
||||
});
|
||||
ui.click_me.on('long_click', () => {
|
||||
toast('我被长按啦');
|
||||
});
|
||||
|
||||
@@ -17,5 +17,5 @@ ui.layout(
|
||||
<text autoLink="web" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
<text autoLink="email" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
<text autoLink="all" margin="8">网址 www.baidu.com, 邮箱 example@qq.com 等</text>
|
||||
</vertical>
|
||||
);
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
@@ -7,10 +7,10 @@ ui.layout(
|
||||
<text textStyle="bold" textColor="black">加粗</text>
|
||||
<text textStyle="italic">斜体</text>
|
||||
<text textColor="#00ff00">原谅色</text>
|
||||
<text margin="8">Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。Android操作系统最初由Andy Rubin开发,主要支持手机。2005年8月由Google收购注资。2007年11月,Google与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。</text>
|
||||
<text maxLines="1" ellipsize="end" margin="8">Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。Android操作系统最初由Andy Rubin开发,主要支持手机。2005年8月由Google收购注资。2007年11月,Google与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。</text>
|
||||
<text maxLines="2" ellipsize="end" margin="8">Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。Android操作系统最初由Andy Rubin开发,主要支持手机。2005年8月由Google收购注资。2007年11月,Google与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。</text>
|
||||
<text margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商/软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text maxLines="1" ellipsize="end" margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商/软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text maxLines="2" ellipsize="end" margin="8">Android 是一种基于 Linux 的自由及开放源代码的操作系统, 主要使用于移动设备, 如智能手机和平板电脑, 由 Google 公司和开放手机联盟领导及开发. 尚未有统一中文名称, 中国大陆地区较多人使用 "安卓" 或 "安致". Android 操作系统最初由 Andy Rubin 开发, 主要支持手机. 2005 年 8 月由 Google 收购注资. 2007 年 11 月, Google 与 84 家硬件制造商/软件开发商及电信营运商组建开放手机联盟共同研发改良 Android 系统.</text>
|
||||
<text w="*" gravity="center" textSize="20sp">居中</text>
|
||||
<text autoLink="all">自动超链接网址www.baidu.com, 邮箱 123@qq.com等</text>
|
||||
</vertical>
|
||||
);
|
||||
<text autoLink="all">自动超链接网址 www.baidu.com, 邮箱 123@qq.com 等</text>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<scroll>
|
||||
<vertical padding="16">
|
||||
<text text="日历样式日期选择" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<datepicker />
|
||||
<datepicker/>
|
||||
|
||||
<text text="滑动日期选择" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<datepicker datePickerMode="spinner"/>
|
||||
|
||||
<text text="时钟样式时间选择" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<timepicker />
|
||||
<timepicker/>
|
||||
|
||||
<text text="滑动时间选择" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<timepicker timePickerMode="spinner"/>
|
||||
|
||||
</vertical>
|
||||
</scroll>
|
||||
)
|
||||
</scroll>,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
var PrefCheckBox = require('./自定义控件-模块-配置勾选框.js');
|
||||
|
||||
@@ -7,12 +7,10 @@ ui.layout(
|
||||
<pref-checkbox id="perf1" text="配置1"/>
|
||||
<pref-checkbox id="perf2" text="配置2"/>
|
||||
<button id="btn" text="获取配置"/>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.btn.on("click", function(){
|
||||
toast("配置1为" + PrefCheckBox.getPref().get("perf1"));
|
||||
toast("配置2为" + PrefCheckBox.getPref().get("perf2"));
|
||||
ui.btn.on('click', function () {
|
||||
toast('配置1为' + PrefCheckBox.getPref().get('perf1'));
|
||||
toast('配置2为' + PrefCheckBox.getPref().get('perf2'));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
var InputLayout = (function() {
|
||||
//继承至ui.Widget
|
||||
var InputLayout = (function () {
|
||||
// 继承至 ui.Widget
|
||||
util.extend(InputLayout, ui.Widget);
|
||||
|
||||
function InputLayout() {
|
||||
ui.Widget.call(this);
|
||||
this.defineAttr("hint", (view, attr, value, defineSetter)=>{
|
||||
this.defineAttr('hint', (view, attr, value, defineSetter) => {
|
||||
view._hint.setText(value);
|
||||
});
|
||||
this.defineAttr("text", (view, attr, value, defineSetter)=>{
|
||||
view._input.setText(value);
|
||||
});
|
||||
this.defineAttr('text', (view, attr, value, defineSetter) => {
|
||||
view._input.setText(value);
|
||||
});
|
||||
}
|
||||
InputLayout.prototype.render = function() {
|
||||
|
||||
InputLayout.prototype.render = function () {
|
||||
return (
|
||||
<vertical>
|
||||
<text id="_hint" textSize="16sp" margin="4" textColor="gray"/>
|
||||
<input id="_input" margin="0 16"/>
|
||||
</vertical>
|
||||
);
|
||||
}
|
||||
InputLayout.prototype.getInput = function() {
|
||||
};
|
||||
InputLayout.prototype.getInput = function () {
|
||||
return this.view._input.getText();
|
||||
};
|
||||
ui.registerWidget("input-layout", InputLayout);
|
||||
ui.registerWidget('input-layout', InputLayout);
|
||||
return InputLayout;
|
||||
})();
|
||||
|
||||
@@ -33,9 +34,9 @@ ui.layout(
|
||||
<input-layout id="name" hint="请输入名字"/>
|
||||
<input-layout id="age" hint="请输入年龄" text="18"/>
|
||||
<button id="ok" text="确认"/>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.ok.on("click", function(){
|
||||
toast("名字是:" + ui.name.widget.getInput() + ", 年龄是:" + ui.age.widget.getInput());
|
||||
});
|
||||
ui.ok.on('click', function () {
|
||||
toast('名字是: ' + ui.name.widget.getInput() + ', 年龄是: ' + ui.age.widget.getInput());
|
||||
});
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
var ColoredButton = (function() {
|
||||
//继承ui.Widget
|
||||
var ColoredButton = (function () {
|
||||
// 继承 ui.Widget
|
||||
util.extend(ColoredButton, ui.Widget);
|
||||
|
||||
function ColoredButton() {
|
||||
//调用父类构造函数
|
||||
// 调用父类构造函数
|
||||
ui.Widget.call(this);
|
||||
//自定义属性color,定义按钮颜色
|
||||
this.defineAttr("color", (view, name, defaultGetter) => {
|
||||
// 自定义属性 color, 定义按钮颜色
|
||||
this.defineAttr('color', (view, name, defaultGetter) => {
|
||||
return this._color;
|
||||
}, (view, name, value, defaultSetter) => {
|
||||
this._color = value;
|
||||
view.attr("backgroundTint", value);
|
||||
view.attr('backgroundTint', value);
|
||||
});
|
||||
//自定义属性onClick,定义被点击时执行的代码
|
||||
this.defineAttr("onClick", (view, name, defaultGetter) => {
|
||||
// 自定义属性 onClick, 定义被点击时执行的代码
|
||||
this.defineAttr('onClick', (view, name, defaultGetter) => {
|
||||
return this._onClick;
|
||||
}, (view, name, value, defaultSetter) => {
|
||||
this._onClick = value;
|
||||
});
|
||||
}
|
||||
ColoredButton.prototype.render = function() {
|
||||
|
||||
ColoredButton.prototype.render = function () {
|
||||
return (
|
||||
<button textSize="16sp" style="Widget.AppCompat.Button.Colored" w="auto"/>
|
||||
);
|
||||
}
|
||||
ColoredButton.prototype.onViewCreated = function(view) {
|
||||
view.on("click", () => {
|
||||
};
|
||||
ColoredButton.prototype.onViewCreated = function (view) {
|
||||
view.on('click', () => {
|
||||
if (this._onClick) {
|
||||
eval(this._onClick);
|
||||
}
|
||||
});
|
||||
}
|
||||
ui.registerWidget("colored-button", ColoredButton);
|
||||
};
|
||||
ui.registerWidget('colored-button', ColoredButton);
|
||||
return ColoredButton;
|
||||
})();
|
||||
|
||||
@@ -41,10 +42,9 @@ ui.layout(
|
||||
<vertical>
|
||||
<colored-button text="第一个按钮" color="#ff5722"/>
|
||||
<colored-button text="第二个按钮" onClick="hello()"/>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
function hello() {
|
||||
alert("Hello ~");
|
||||
|
||||
alert('Hello ~');
|
||||
}
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
|
||||
//这个自定义控件是一个勾选框checkbox,能够保存自己的勾选状态,在脚本重新启动时能恢复状态
|
||||
var PrefCheckBox = (function() {
|
||||
//继承至ui.Widget
|
||||
// 这个自定义控件是一个勾选框 checkbox, 能够保存自己的勾选状态, 在脚本重新启动时能恢复状态
|
||||
var PrefCheckBox = (function () {
|
||||
// 继承至 ui.Widget
|
||||
util.extend(PrefCheckBox, ui.Widget);
|
||||
|
||||
function PrefCheckBox() {
|
||||
//调用父类构造函数
|
||||
// 调用父类构造函数
|
||||
ui.Widget.call(this);
|
||||
//自定义属性key,定义在配置中保存时的key
|
||||
this.defineAttr("key");
|
||||
// 自定义属性 key, 定义在配置中保存时的 key
|
||||
this.defineAttr('key');
|
||||
}
|
||||
PrefCheckBox.prototype.render = function() {
|
||||
|
||||
PrefCheckBox.prototype.render = function () {
|
||||
return (
|
||||
<checkbox />
|
||||
<checkbox/>
|
||||
);
|
||||
}
|
||||
PrefCheckBox.prototype.onFinishInflation = function(view) {
|
||||
};
|
||||
PrefCheckBox.prototype.onFinishInflation = function (view) {
|
||||
view.setChecked(PrefCheckBox.getPref().get(this.getKey(), false));
|
||||
view.on("check", (checked) => {
|
||||
view.on('check', (checked) => {
|
||||
PrefCheckBox.getPref().put(this.getKey(), checked);
|
||||
});
|
||||
}
|
||||
PrefCheckBox.prototype.getKey = function() {
|
||||
if(this.key){
|
||||
};
|
||||
PrefCheckBox.prototype.getKey = function () {
|
||||
if (this.key) {
|
||||
return this.key;
|
||||
}
|
||||
let id = this.view.attr("id");
|
||||
if(!id){
|
||||
throw Error("should set a id or key to the checkbox");
|
||||
let id = this.view.attr('id');
|
||||
if (!id) {
|
||||
throw Error('should set a id or key to the checkbox');
|
||||
}
|
||||
return id.replace("@+id/", "");
|
||||
}
|
||||
PrefCheckBox.setPref = function(pref) {
|
||||
return id.replace('@+id/', '');
|
||||
};
|
||||
PrefCheckBox.setPref = function (pref) {
|
||||
PrefCheckBox._pref = pref;
|
||||
}
|
||||
PrefCheckBox.getPref = function(){
|
||||
if(!PrefCheckBox._pref){
|
||||
PrefCheckBox._pref = storages.create("pref");
|
||||
};
|
||||
PrefCheckBox.getPref = function () {
|
||||
if (!PrefCheckBox._pref) {
|
||||
PrefCheckBox._pref = storages.create('pref');
|
||||
}
|
||||
return PrefCheckBox._pref;
|
||||
}
|
||||
ui.registerWidget("pref-checkbox", PrefCheckBox);
|
||||
};
|
||||
ui.registerWidget('pref-checkbox', PrefCheckBox);
|
||||
return PrefCheckBox;
|
||||
})();
|
||||
|
||||
module.exports = PrefCheckBox;
|
||||
module.exports = PrefCheckBox;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,41 +1,41 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
<text text="输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input />
|
||||
<text text="输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input/>
|
||||
|
||||
<!-- hint属性用来设置输入框的提示-->
|
||||
<text text="带提示的输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input hint="请输入一些内容"/>
|
||||
<!-- hint 属性用来设置输入框的提示 -->
|
||||
<text text="带提示的输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input hint="请输入一些内容"/>
|
||||
|
||||
<!-- inputType属性用来设置输入类型,包括number, email, phone等-->
|
||||
<text text="数字输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input inputType="number" text="123"/>
|
||||
<!-- inputType 属性用来设置输入类型, 包括 number, email, phone 等 -->
|
||||
<text text="数字输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input inputType="number" text="123"/>
|
||||
|
||||
<!-- password属性用来设置输入框是否是密码输入框 -->
|
||||
<text text="密码输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input password="true"/>
|
||||
<!-- password 属性用来设置输入框是否是密码输入框 -->
|
||||
<text text="密码输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input password="true"/>
|
||||
|
||||
<!-- lines属性用来设置输入框的行数 -->
|
||||
<text text="多行输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input lines="3"/>
|
||||
<!-- lines 属性用来设置输入框的行数 -->
|
||||
<text text="多行输入框" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input lines="3"/>
|
||||
|
||||
<text text="设置输入框错误信息" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input id="qq" inputType="number" hint="请输入您的QQ号码"/>
|
||||
<button id="ok" text="确定" w="auto" style="Widget.AppCompat.Button.Colored"/>
|
||||
</vertical>
|
||||
<text text="设置输入框错误信息" textColor="black" textSize="16sp" marginTop="16"/>
|
||||
<input id="qq" inputType="number" hint="请输入您的 QQ 号码"/>
|
||||
<button id="ok" text="确定" w="auto" style="Widget.AppCompat.Button.Colored"/>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
ui.ok.click(()=>{
|
||||
ui.ok.click(() => {
|
||||
var text = ui.qq.text();
|
||||
if(text.length === 0){
|
||||
ui.qq.setError("输入不能为空");
|
||||
if (text.length === 0) {
|
||||
ui.qq.setError('输入不能为空');
|
||||
return;
|
||||
}
|
||||
var qq = parseInt(text);
|
||||
if(qq < 10000){
|
||||
ui.qq.setError("QQ号码格式错误");
|
||||
if (qq < 10000) {
|
||||
ui.qq.setError('QQ 号码格式错误');
|
||||
return;
|
||||
}
|
||||
ui.qq.setError(null);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"ui";
|
||||
'ui';
|
||||
|
||||
ui.layout(
|
||||
<vertical padding="16">
|
||||
<text text="处理中..." textColor="black" textSize="16sp"/>
|
||||
<progressbar />
|
||||
<progressbar/>
|
||||
|
||||
<text text="直线无限进度条" textColor="black" textSize="16sp" marginTop="24"/>
|
||||
<progressbar indeterminate="true" style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"/>
|
||||
@@ -19,38 +19,38 @@ ui.layout(
|
||||
<progressbar id="progress" w="*" style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"/>
|
||||
</horizontal>
|
||||
<button id="download">开始下载</button>
|
||||
</vertical>
|
||||
</vertical>,
|
||||
);
|
||||
|
||||
var downloadId = null;
|
||||
|
||||
ui.download.click(()=>{
|
||||
if(downloadId){
|
||||
ui.download.click(() => {
|
||||
if (downloadId) {
|
||||
stopDownload();
|
||||
}else{
|
||||
} else {
|
||||
startDownload();
|
||||
}
|
||||
});
|
||||
|
||||
function stopDownload(){
|
||||
ui.download.text("开始下载");
|
||||
function stopDownload() {
|
||||
ui.download.text('开始下载');
|
||||
clearInterval(downloadId);
|
||||
downloadId = null;
|
||||
}
|
||||
|
||||
function startDownload(){
|
||||
if(ui.progress.getProgress() === 100){
|
||||
function startDownload() {
|
||||
if (ui.progress.getProgress() === 100) {
|
||||
ui.progress.setProgress(0);
|
||||
}
|
||||
ui.download.text("停止下载");
|
||||
downloadId = setInterval(()=>{
|
||||
ui.download.text('停止下载');
|
||||
downloadId = setInterval(() => {
|
||||
var p = ui.progress.getProgress();
|
||||
p++;
|
||||
if(p > 100){
|
||||
if (p > 100) {
|
||||
stopDownload();
|
||||
return;
|
||||
}
|
||||
ui.progress.setProgress(p);
|
||||
ui.progress_value.setText(p.toString());
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
console.show();
|
||||
|
||||
log("将产生5个1到100的随机数");
|
||||
log('将产生 5 个 1 到 100 的随机数');
|
||||
|
||||
for(let i = 0; i < 5; i++){
|
||||
for (let i = 0; i < 5; i++) {
|
||||
print(random(1, 100));
|
||||
print(" ");
|
||||
print(' ');
|
||||
sleep(400);
|
||||
}
|
||||
print("\n");
|
||||
print('\n');
|
||||
|
||||
log("将产生10个1到20的不重复随机数");
|
||||
log('将产生 10 个 1 到 20 的不重复随机数');
|
||||
|
||||
var exists = {};
|
||||
|
||||
for(let i = 0; i < 10; i++){
|
||||
for (let i = 0; i < 10; i++) {
|
||||
var r;
|
||||
do{
|
||||
do {
|
||||
r = random(1, 20);
|
||||
}while(exists[r]);
|
||||
} while (exists[r]);
|
||||
exists[r] = true;
|
||||
print(r + " ");
|
||||
print(r + ' ');
|
||||
sleep(400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
console.setGlobalLogConfig({
|
||||
file: "/sdcard/log.txt"
|
||||
file: '/sdcard/log.txt',
|
||||
});
|
||||
console.log(1);
|
||||
console.log(2);
|
||||
console.error(3);
|
||||
app.viewFile("/sdcard/log.txt");
|
||||
app.viewFile('/sdcard/log.txt');
|
||||
|
||||
@@ -9,4 +9,4 @@ try {
|
||||
console.assert(false, `Text from \`console.assert\``);
|
||||
} catch (e) {
|
||||
/* Ignored. */
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user