群里有人问, 也不难, 也花不了多少时间, 那就贴一下答案.
牙叔教程 简单易懂
autojs版本: 8.8.20
console.show(); let mConsoleView = getConsoleWindow(); let parent = mConsoleView.parent; var inputView = parent.findViewById(context.getResources().getIdentifier("input", "id", context.getPackageName())); var buttonView = parent.findViewById(context.getResources().getIdentifier("submit", "id", context.getPackageName())); var consoleView = parent.findViewById(context.getResources().getIdentifier("console", "id", context.getPackageName())); console.setSize(1000, 1000); ui.run(function () { inputView.setVisibility(8); buttonView.setVisibility(8); }); let r = filterView(mConsoleView); r[3].setText("牙叔教程 简单易懂"); for (var i = 0; i < 5; i++) { log("牙叔教程 简单易懂"); sleep(1000); } ui.run(function () { log(r[5].performClick()); }); setInterval(function () {}, 1000); /* -------------------------------------------------------------------------- */ function getConsoleWindow() { var mConsole = runtime.console; let field = mConsole.class.superclass.getDeclaredField("mConsoleFloaty"); field.setAccessible(true); mConsoleFloaty = field.get(mConsole); mConsoleView = mConsoleFloaty.getExpandedView(); return mConsoleView; } function filterView(view, arr) { arr = arr || []; if (view instanceof android.view.ViewGroup) { arr.push(view); let childCount = view.childCount; for (var i = 0; i < childCount; i++) { let chileView = view.getChildAt(i); filterView(chileView, arr); } } else { arr.push(view); } return arr; }
autojs版本: 4.1.1 Alpha
console.show(); toastLog(app.versionName); let mConsoleView = getConsoleWindow(); let parent = mConsoleView.parent; var inputView = parent.findViewById(context.getResources().getIdentifier("input", "id", context.getPackageName())); var buttonView = parent.findViewById(context.getResources().getIdentifier("submit", "id", context.getPackageName())); var consoleView = parent.findViewById(context.getResources().getIdentifier("console", "id", context.getPackageName())); console.setSize(1000, 1000); ui.run(function () { inputView.setVisibility(8); buttonView.setVisibility(8); }); let r = filterView(mConsoleView); r[3].setText("牙叔教程 简单易学"); for (var i = 0; i < 5; i++) { log("牙叔教程 简单易学"); sleep(1000); } ui.run(function () { log(r[5].performClick()); }); setInterval(function () {}, 1000); /* -------------------------------------------------------------------------- */ function getConsoleWindow() { var field = runtime.console.class.getDeclaredField("mConsoleFloaty"); field.setAccessible(true); mConsoleView = field.get(runtime.console).getExpandedView(); return mConsoleView; } function filterView(view, arr) { arr = arr || []; if (view instanceof android.view.ViewGroup) { arr.push(view); let childCount = view.childCount; for (var i = 0; i < childCount; i++) { let chileView = view.getChildAt(i); filterView(chileView, arr); } } else { arr.push(view); } return arr; }
参考
名人名言
思路是最重要的, 其他的百度, bing, stackoverflow, 安卓文档, autojs文档, 最后才是群里问问
--- 牙叔教程
声明
部分内容来自网络
本教程仅用于学习, 禁止用于其他用途