This commit is contained in:
2026-01-28 21:43:16 +08:00
parent 5b15529eee
commit 5f0d79aa92
6 changed files with 1629 additions and 1 deletions

101
autojs/phonepe.js Normal file
View File

@@ -0,0 +1,101 @@
// 先打开 PhonePe 应用
console.log("正在启动 PhonePe 应用...");
app.launch("com.phonepe.app");
// 等待应用加载
// sleep(3000);
// 简化:直接通过 id 查找并点击,找不到则坐标点击后备
console.log("开始搜索 tvPay (com.phonepe.app:id/tvPay) 元素...");
var el = id("com.phonepe.app:id/tvPay").findOne(1000);
if (el) {
console.log("找到 tvPay尝试 click()...");
if (!el.click()) {
var b = el.bounds();
click(Math.floor((b.left + b.right) / 2), Math.floor((b.top + b.bottom) / 2));
}
console.log("点击完成");
} else {
console.log("未找到 tvPay使用默认坐标点击作为后备");
// 请根据设备分辨率调整坐标
click(360, 1440);
console.log("后备坐标点击已执行");
}
// 等待支付界面加载
sleep(5000);
// 填写金额
var amountEl = id("com.phonepe.app:id/et_amount").findOne(2000);
if (amountEl) {
amountEl.click();
sleep(300);
amountEl.setText('1');
} else {
input('1');
}
sleep(1000);
// 填写备注
var notesEl = id("com.phonepe.app:id/et_notes").findOne(2000);
if (notesEl) {
notesEl.click();
sleep(300);
notesEl.setText('No Body');
} else {
input('No Body');
}
sleep(1000);
// 点击继续
var proceedEl = id("com.phonepe.app:id/fl_proceed_bar_container").findOne(2000);
if (proceedEl) {
console.log("找到继续按钮,尝试 click()...");
// proceedEl.click();
click(360, 950);
} else {
console.log("未找到继续按钮,使用默认坐标点击作为后备");
click(360, 950);
}
sleep(3000);
// 最后点击支付
click(360, 1436); // 点击支付
// 定义函数:查找并点击 clickable 的控件,包含指定文本
function findAndClickByText(text) {
var elements = className('TextView').clickable(true).find();
console.log("找到 " + elements.length + " 个 clickable TextView 控件");
for (var i = 0; i < elements.length; i++) {
var elementText = elements[i].text();
console.log("控件 " + (i + 1) + ": [" + elementText + "]");
if (elementText == text) {
console.log("找到匹配的控件: " + text + ",点击中...");
elements[i].click();
sleep(300);
return true;
}
}
console.log("未找到包含 '" + text + "' 的控件");
return false;
}
// 输入 pin
sleep(2000);
console.log("开始使用 clickable 控件输入 PIN 1123...");
sleep(300);
// 依次点击: 1, 1, 2, 3
var sequence = ['1', '1', '2', '3'];
for (var j = 0; j < sequence.length; j++) {
console.log("\\n第 " + (j + 1) + " 步: 查找并点击数字 " + sequence[j]);
findAndClickByText(sequence[j]);
}
sleep(1000);
click(600, 1418);
console.log("PIN 输入完成,支付流程结束。");