下载地址:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:6753
完整UI界面:包含坐标设置、间隔时间、随机偏移等参数配置区域
核心点击功能:支持自定义点击位置、间隔时间和随机偏移量
位置记录功能:可实时捕获屏幕坐标位置
状态统计:实时显示总点击次数
高级设置面板:可配置点击持续时间等高级参数
悬浮窗设计:支持拖动位置,不影响其他操作
线程安全:点击操作在独立线程中运行
错误处理:完善的异常捕获机制
无障碍服务检测:自动检查并提示开启必要权限
// 基础配置参数
let config = {
version: "2.1.0",
clickInterval: 500, // 默认点击间隔(ms)
clickDuration: 50, // 点击持续时间(ms)
clickPosition: {x: 500, y: 800}, // 默认点击位置
randomRange: 20, // 随机偏移范围
totalClickCount: 0, // 总点击次数统计
isRunning: false // 运行状态标志
};
// UI界面构建
function createUI() {
// 主窗口设置
let window = floaty.window(
<horizontal gravity="center">
<text text="X:" textSize="16sp" marginRight="4"/>
<input id="xPos" inputType="number"
text="" + config.clickPosition.x
w="60" marginRight="8"/>
<text text="Y:" textSize="16sp" marginRight="4"/>
<input id="yPos" inputType="number"
text="" + config.clickPosition.y
w="60"/>
</horizontal>
<horizontal gravity="center" marginTop="8">
<text text="间隔(ms):" textSize="16sp" marginRight="4"/>
<input id="interval" inputType="number"
text="" + config.clickInterval
w="80" marginRight="8"/>
<text text="随机偏移:" textSize="16sp" marginRight="4"/>
<input id="randomRange" inputType="number"
text="" + config.randomRange
w="60"/>
</horizontal>
<button id="startBtn" text="开始"
bg="#FF5722" textColor="#FFFFFF"
marginTop="12" w="*"/>
<button id="recordBtn" text="记录位置"
bg="#2196F3" textColor="#FFFFFF"
marginTop="8" w="*"/>
<horizontal gravity="center" marginTop="12">
<text text="总点击次数:" textSize="14sp" marginRight="4"/>
<text id="clickCount" text="0"
textSize="14sp" textColor="#FFEB3B"/>
</horizontal>
<button id="settingsBtn" text="高级设置"
bg="#607D8B" textColor="#FFFFFF"
marginTop="8" w="*"/>
</vertical>
</frame>
);
// 控件引用
let ui = {
window: window,
xPos: window.xPos,
yPos: window.yPos,
interval: window.interval,
randomRange: window.randomRange,
startBtn: window.startBtn,
recordBtn: window.recordBtn,
clickCount: window.clickCount,
settingsBtn: window.settingsBtn
};
return ui;
}
// 高级设置面板
function showAdvancedSettings() {
dialogs.build({
title: "高级设置",
content: (() => {
let view = new android.widget.ScrollView(context);
let layout = new android.widget.LinearLayout(context);
layout.setOrientation(1); // VERTICAL
// 点击持续时间设置
let durationLayout = new android.widget.LinearLayout(context);
durationLayout.setOrientation(0); // HORIZONTAL
let durationText = new android.widget.TextView(context);
durationText.setText("点击持续时间(ms):");
let durationInput = new android.widget.EditText(context);
durationInput.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
durationInput.setText("" + config.clickDuration);
durationLayout.addView(durationText);
durationLayout.addView(durationInput);
// 其他高级设置项...
layout.addView(durationLayout);
view.addView(layout);
return view;
})(),
positive: "保存",
negative: "取消"
}).on("positive", () => {
// 保存设置逻辑
}).show();
}
// 点击操作线程
function clickThread(ui) {
threads.start(function() {
while (config.isRunning) {
try {
// 获取当前配置
let x = parseInt(ui.xPos.getText());
let y = parseInt(ui.yPos.getText());
let interval = parseInt(ui.interval.getText());
let randomRange = parseInt(ui.randomRange.getText());
// 添加随机偏移
if (randomRange > 0) {
x += random(-randomRange, randomRange);
y += random(-randomRange, randomRange);
}
// 执行点击操作
press(x, y, config.clickDuration);
// 更新点击计数
config.totalClickCount++;
ui.clickCount.setText("" + config.totalClickCount);
// 间隔等待
sleep(interval);
} catch (e) {
log(e);
break;
}
}
});
}
// 主程序入口
function main() {
// 检查无障碍服务
if (!auto.service) {
toast("请先开启无障碍服务");
auto.waitFor();
}
// 创建UI
let ui = createUI();
// 按钮事件绑定
ui.startBtn.click(() => {
config.isRunning = !config.isRunning;
if (config.isRunning) {
ui.startBtn.setText("停止");
ui.startBtn.setBackgroundColor("#F44336");
clickThread(ui);
} else {
ui.startBtn.setText("开始");
ui.startBtn.setBackgroundColor("#FF5722");
}
});
ui.recordBtn.click(() => {
toast("请在3秒内点击要记录的位置");
threads.start(function() {
let pos = captureScreen().findColor(colors.toString(colors.rgb(255, 0, 0)));
if (pos) {
ui.xPos.setText("" + pos.x);
ui.yPos.setText("" + pos.y);
toast("位置已记录: " + pos.x + ", " + pos.y);
}
});
});
ui.settingsBtn.click(() => {
showAdvancedSettings();
});
// 窗口拖动支持
let windowX = 0, windowY = 0;
let downTime = 0;
ui.window.setTouchable(true);
ui.window.setOnTouchListener(function(view, event) {
switch(event.getAction()) {
case event.ACTION_DOWN:
windowX = event.getRawX() - ui.window.getX();
windowY = event.getRawY() - ui.window.getY();
downTime = new Date().getTime();
return true;
case event.ACTION_MOVE:
if (new Date().getTime() - downTime > 100) {
ui.window.setPosition(
event.getRawX() - windowX,
event.getRawY() - windowY
);
}
return true;
}
return false;
});
}
// 启动主程序
main();