//此代码由飞云脚本圈整理提供(www.feiyunjs.com)
"ui";
importClass(android.graphics.Color);
importClass(android.graphics.drawable.ColorDrawable);
importClass(android.app.Dialog);
importClass(android.view.Gravity);
importClass(android.app.AlertDialog);
ui.layout(
<vertical bg="#ffffffff">
<linear h="30">
<text padding="6 2 0 0" android:ellipsize="start" android:singleLine="true" android:scrollHorizontally="true"
size="18" id="currpath"/>
</linear>
<list id="list" h="*" w="*">
<relative w="1000" h="45" foreground="?selectableItemBackground">
<img tint="{{this.icontint}}" id="icon" w="25" src="@drawable/{{this.icon}}"/>
<text size="16" layout_toRightOf="icon" layout_centerVertical="true" text="{{this.title}}"/>
</relative>
</list>
</vertical>)
var updateList=function(path){
ui.currpath.setText(path.replace(context.getDataDir().getPath(),"..."));
var arr=files.listDir(path)
arr.sort(function(a,b){
return a.toLowerCase()==b.toLowerCase()?0:(a.toLowerCase()>b.toLowerCase()?1:-1)
});
var filelist=new Array();
filelist.push({icon:"ic_keyboard_arrow_up_black_48dp",icontint:"#000000",title:" ..."});
for(var i=0;i<arr.length;i++)
filelist.push({icon:files.isDir(currPath+arr[i])?"ic_folder_black_48dp":"ic_insert_drive_file_black_48dp",icontint:files.isDir(currPath+arr[i])?"#657890":"#011345",title:arr[i]});
ui.list.setDataSource(filelist)
}
ui.list.on("item_click", function (item, i, itemView, listView) {
if(i==0){
if(currPath!=context.getDataDir().getPath()+"/"){
var ss=currPath.substring(0,currPath.length-1)
currPath=ss.substring(0,ss.lastIndexOf("/")+1);
updateList(currPath);
}
return;
}
if(files.isDir(currPath+item.title)){updateList(currPath+=item.title+"/");return;}
});
var currPath=context.getDataDir().getPath()+"/";
updateList(currPath);
说明
本文提供的代码仅供参考。
可能有些地方在最新版本的Auto.js上面需要做修改,才能运行。
Auto.js简介
Auto.js是利用安卓系统的“辅助功能”实现类似于按键精灵一样,可以通过代码模拟一系列界面动作的辅助工作。
与“按键精灵”不同的是,它的模拟动作并不是简单的使用在界面定坐标点来实现,而是类似与win一般,找窗口句柄来实现的。
Auto.js使用JavaScript作为脚本语言,目前使用Rhino 1.7.7.2作为脚本引擎,支持ES5与部分ES6特性。
开发文档
Auto.js Pro开发文档优化版
文档尚在完善中,可能有文档描述和代码实际行为有出入的情况。
模板、样式、generator来自Node.js。
为什么要使用Auto.js Pro开发脚本,有什么特点?
吸引我使用Auto.js Pro的原因有很多。最主要的几个原因是:
- Auto.js Pro能开发免ROOT的安卓脚本
- Auto.js Pro基于节点操作,能开发全分辨率的脚本,自动适配各种安卓机型
- Auto.js Pro丰富的UI组件,能自定义各种样式的安卓界面
- Auto.js Pro使用的javascript的语法比较优雅,代码可读性强
- Auto.js Pro的命令库非常的丰富,接口比较多
- Auto.js Pro脚本文件体积比较小。1000行的代码,打包后的apk文件只有3-5M,还没有广告