-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Automation: Auto.js #350
Comments
Android 自动化助手方案: Auto.js项目:
AutoJsPro Pro 8.8.20-0
vscode 插件:技术原理:
ref: |
Auto.js 参考示例:
|
抢菜助手:
// 解锁手机屏幕
function unLock() {
if (!device.isScreenOn()) {
device.wakeUp();
sleep(500);
swipe(500, 2000, 500, 1000, 200);
sleep(500);
const password = "123456"; //这里换成自己的手机解锁密码
for (let i = 0; i < password.length; i++) {
let position = text(password[i]).findOne().bounds();
click(position.centerX(), position.centerY());
sleep(100);
}
}
sleep(1000);
}
//抢菜流程
function robVeg() {
// 解锁手机屏幕:
unLock();
// 打开买菜 app:
launchApp("美团买菜");
waitForPackage("com.meituan.retail.v.android", 200);
// 检查无障碍权限:
auto.waitFor();
//
// app 跳过广告:
//
const btn_skip = id("btn_skip").findOne();
if (btn_skip) {
btn_skip.click();
toast("已跳过首屏广告");
}
sleep(2000);
// 购物车:
gotoBuyCar();
sleep(2000);
// 检查:
checkAll();
sleep(2000);
// 提交订单:
submitOrder(0);
}
robVeg();
//打开购物车页面
function gotoBuyCar() {
if (id("img_shopping_cart").exists()) {
id("img_shopping_cart").findOne().parent().click();
toast("已进入购物车");
} else {
toast("没找到购物车");
exit;
}
}
//勾选全部商品
function checkAll() {
const isCheckedAll = textStartsWith("结算(").exists();
// todo x: button:
const checkAllBtn = text("全选").findOne();
if (!!checkAllBtn) {
!isCheckedAll && checkAllBtn.parent().click();
sleep(1000);
} else {
toast("没找到全选按钮");
exit;
}
}
function submitOrder(count) {
//
// 结算按钮:
//
if (textStartsWith("结算(").exists()) {
//
//
//
textStartsWith("结算(").findOne().parent().click();
} else if (text("我知道了").exists()) {
//
//
//
toast("关闭 >> 我知道了");
//
// todo x: key button
//
text("我知道了").findOne().parent().click();
} else if (text("返回购物车").exists()) {
text("返回购物车").findOne().parent().click();
toast(">> 返回购物车");
} else if (text("重新加载").exists()) {
toast("重新加载");
text("重新加载").findOne().parent().click();
} else if (text("立即支付").exists()) {
text("立即支付").findOne().parent().click();
} else if (text("确认支付").exists()) {
const music =
"/storage/emulated/0/netease/cloudmusic/Music/Joel Hanson Sara Groves - Traveling Light.mp3";
media.playMusic(music);
sleep(media.getMusicDuration());
} else {
//
//
//
toast(">> 抢个屁!");
exit;
}
//
//
//
sleep(800);
if (count > 10000) {
toast("没抢到");
exit;
}
submitOrder(count++);
} |
Auto.js 使用流程:1. 下载安装 auto.js 的 apk 包:
2. 安装
|
2024 update:
脚本集合:
安卓应用商店:
|
1 |
This was referenced Jun 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related:
The text was updated successfully, but these errors were encountered: