Auto JS 文件類操作


back();  //返回鍵


home();  //主頁HOME

powerDialog();  //彈出電源菜單


notifications(); //拉出通知欄


quickSettings();  //顯示快速設置(下拉通知欄到底)


recents(); //顯示最近任務

splitScreen(); //分屏


Menu();  //模擬按下菜單鍵。 此函數依賴於root權限。



VolumeUp(); //按下音量上鍵。(增音) 此函數依賴於root權限。

VolumeDown(); //按鍵音量上鍵。 此函數依賴於root權限。



Text("sfsdf545"); //只能為英文或英文符號,或者數字,不可以是中文



files.isDir("/sdcard/文件夾/"); //返回路徑path是否是文件夾


files.isDir("/sdcard/文件.txt");  //返回路徑path是否是文件

files.isEmptyDir("/sdcard/123");  //是否為空文件夾,空文件夾返回 true ,否則為 false



files.join("/sdcard/", "1.txt");  // 合並,兩個路徑,返回為一個整體


files.create("/sdcard/8888.txt");   //新建文件或者文件夾(文件夾 目前創建失敗)

files.createWithDirs("/sdcard/新文件夾/新文件夾/新文件夾/2.txt");創建一個文件或文件夾並返回是否創建成功。如果文件所在文件夾不存在,則先創建他所在的一系列文件夾。如果文件已經存在,則直接返回false


files.exists("/sdcard/新文件夾");  //返回文件夾/文件 是否存在

files.ensureDir("/sdcard/Download/ABC/");//新建多級文件夾


files.read("/sdcard/1.txt",encoding = "UTF-8");    //讀取文本的內容,第二個參數可以設置編碼


files.readBytes(path);   // https://hyb1996.github.io/AutoJs-Docs/#/files?id=filesreadbytespath



files.write("/sdcard/38.txt","宋祖兒劉亦菲",encoding = "utf-8"); //寫內容到文件,如果文件存在則覆蓋,不存在則創建。(覆寫)

app.viewFile("/sdcard/1.txt");//打開文本 




files.writeBytes(path, bytes); //https://hyb1996.github.io/AutoJs-Docs/#/files?id=fileswritebytespath-bytes


files.appendBytes(path, text[, encoding = 'utf-8']); //https://hyb1996.github.io/AutoJs-Docs/#/files?id=filesappendbytespath-text-encoding-39utf-839

files.append("/sdcard/cao.txt","上他倆",encoding="UTF-8");  //追加文本內容,文件不存在則創建 



files.copy("/sdcard/1.txt", "/sdcard/666/999.txt");   //復制文件,如果文件夾不存在 則會自動創建.


files.move("/sdcard/520.txt", "/sdcard/123/1.txt");   //移動文件,文件夾 不存在 則會移動失敗.


files.rename("/sdcard/1.txt", "2.txt");  //重命名 文件 /文件夾  的名字.


files.rename("/sdcard/888.txt", "666.exe");  //重命名 文件 /文件夾  的名字.


files.getName("/sdcard/劉亦菲.txt");  //無論是否存在,都返回 文件/文件夾 名稱  "劉亦菲.txt"


files.getNameWithoutExtension("/sdcard/劉亦菲.txt");     //無論是否存在,都返回 文件/文件夾 名稱  "劉亦菲"


files.getExtension("/sdcard/劉亦菲.txt");  //返回 文件后綴名   "txt"


files.remove("/sdcard/劉亦菲.txt");  //刪除文件  或者 [空的文件夾]



files.removeDir("/sdcard/文件夾");   //刪除文件夾,如果文件夾不為空,則刪除該文件夾的所有內容再刪除該文件夾,返回是否全部刪除成功。


files.getSdcardPath();   //返回SD卡的路徑


files.cwd();
返回腳本的"當前工作文件夾路徑"。該路徑指的是,如果腳本本身為腳本文件,則返回這個腳本文件所在目錄;否則返回null獲取其他設定路徑。

例如,對於腳本文件"/sdcard/腳本/1.js"運行files.cwd()返回"/sdcard/腳本/"。




files.path(relativePath);
返回相對路徑對應的絕對路徑。例如files.path("./1.png"),如果運行這個語句的腳本位於文件夾"/sdcard/腳本/"中,則返回"/sdcard/腳本/1.png"。





//遍歷文件夾下所有的文件夾和文件
var arr = files.listDir("/sdcard/新文件夾/");

for(i=0;i<=arr.length;i++){
    toast(arr[i]);
}

//列出腳本目錄下所有js腳本文件為,https://hyb1996.github.io/AutoJs-Docs/#/files?id=fileslistdirpath-filter
var dir = "/sdcard/腳本/";
var jsFiles = files.listDir(dir, function(name){
    return name.endsWith(".js") && files.isFile(files.join(dir, name));
});
toast(jsFiles);



===========================================

沒有弄清楚的:

Camera();

Up();

Down();

Left();

Right();

KeyCode(code); //在手機上不行

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM