|
|
|
@ -0,0 +1,578 @@
|
|
|
|
|
//悬浮窗主界面
|
|
|
|
|
var img_url = "http://cdnjson.com/images/2024/10/08/35521ea90f9dd7b5eb70563751db3f09.jpg";
|
|
|
|
|
|
|
|
|
|
suspendedWindow();
|
|
|
|
|
|
|
|
|
|
function suspendedWindow() {
|
|
|
|
|
window = floaty.rawWindow(
|
|
|
|
|
<horizontal gravity="center_vertical">
|
|
|
|
|
<img id="floaty_icon" src="{{img_url}}" w="40" h="40" alpha="0.8" circle="true" borderWidth="1dp" borderColor="black" />
|
|
|
|
|
<vertical id="v_drawer">
|
|
|
|
|
<button id="btn1" textColor="#FFFFFF" text="自动打开直播" bg="#4F4F4F" padding="0" h="70" w="70" />
|
|
|
|
|
<text text="" h="1" />
|
|
|
|
|
<button id="btn2" textColor="#FFFFFF" text="编辑文本" bg="#4F4F4F" padding="0" h="70" w="70" />
|
|
|
|
|
<text text="" h="1" />
|
|
|
|
|
<button id="btn3" textColor="#FFFFFF" text="滑屏、点赞、关注" bg="#4F4F4F" padding="0" h="70" w="70" />
|
|
|
|
|
<text text="" h="1" />
|
|
|
|
|
<button id="btn4" textColor="#FFFFFF" text="自动点赞" bg="#4F4F4F" padding="0" h="70" w="70" />
|
|
|
|
|
<text text="" h="1" />
|
|
|
|
|
<button id="btn5" textColor="#FFFFFF" text="发表评论" bg="#4F4F4F" padding="0" h="70" w="70" />
|
|
|
|
|
</vertical>
|
|
|
|
|
</horizontal>
|
|
|
|
|
);
|
|
|
|
|
window.setPosition(50, device.height / 3);
|
|
|
|
|
window.exitOnClose();
|
|
|
|
|
setInterval(() => { }, 1000);
|
|
|
|
|
|
|
|
|
|
var x = 0, y = 0;
|
|
|
|
|
var windowX, windowY;
|
|
|
|
|
var downTime;
|
|
|
|
|
console.log("w=" + device.width);
|
|
|
|
|
console.log("h=" + device.height);
|
|
|
|
|
window.floaty_icon.setOnTouchListener(function (view, event) {
|
|
|
|
|
switch (event.getAction()) {
|
|
|
|
|
case event.ACTION_DOWN:
|
|
|
|
|
x = event.getRawX();
|
|
|
|
|
y = event.getRawY();
|
|
|
|
|
windowX = window.getX();
|
|
|
|
|
windowY = window.getY();
|
|
|
|
|
downTime = new Date().getTime();
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_MOVE:
|
|
|
|
|
let movexx = windowX + (event.getRawX() - x);
|
|
|
|
|
let moveyy = windowY + (event.getRawY() - y);
|
|
|
|
|
if (movexx < 0 || movexx > device.width) {
|
|
|
|
|
movexx = 0;
|
|
|
|
|
}
|
|
|
|
|
if (moveyy < 0 || moveyy > device.height) {
|
|
|
|
|
moveyy = 0;
|
|
|
|
|
}
|
|
|
|
|
window.setPosition(movexx, moveyy);
|
|
|
|
|
console.log("event y=" + event.getRawY());
|
|
|
|
|
console.log("event x=" + event.getRawX());
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_UP:
|
|
|
|
|
if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
|
|
|
|
|
drawerStatus();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function drawerStatus() {
|
|
|
|
|
var v_drawer = window.v_drawer;
|
|
|
|
|
if (v_drawer.visibility == 0) {
|
|
|
|
|
v_drawer.visibility = 4;
|
|
|
|
|
} else {
|
|
|
|
|
v_drawer.visibility = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 功能1按钮事件
|
|
|
|
|
window.btn1.setOnTouchListener(function (view, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_UP) {
|
|
|
|
|
toast("功能1被点击");
|
|
|
|
|
threads.start(function () { // 创建新线程执行耗时操作
|
|
|
|
|
// 启动小红书APP
|
|
|
|
|
launchApp("小红书");
|
|
|
|
|
|
|
|
|
|
// 等待小红书启动完成,这里等待2秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(2000);
|
|
|
|
|
click("发现");
|
|
|
|
|
|
|
|
|
|
// 执行下滑操作,参数分别是:操作类型(滑动),起始X坐标,起始Y坐标,结束X坐标,结束Y坐标,持续时间
|
|
|
|
|
swipe(500, 1000, 500, 1100, 500);
|
|
|
|
|
|
|
|
|
|
// 等待滑动动画完成,这里等待500毫秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(500);
|
|
|
|
|
|
|
|
|
|
click("直播");
|
|
|
|
|
|
|
|
|
|
sleep(3000);
|
|
|
|
|
|
|
|
|
|
click(800, 1000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 功能2按钮事件
|
|
|
|
|
window.btn2.setOnTouchListener(function (view, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_UP) {
|
|
|
|
|
toast("功能2被点击");
|
|
|
|
|
threads.start(function() {
|
|
|
|
|
auto(); // 启用Auto.js的自动化功能
|
|
|
|
|
|
|
|
|
|
// 启动小红书APP
|
|
|
|
|
launchApp("小红书");
|
|
|
|
|
|
|
|
|
|
// 等待小红书启动完成,这里等待4秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(4000);
|
|
|
|
|
|
|
|
|
|
setScreenMetrics(1200, 2652);
|
|
|
|
|
click(535,2550);
|
|
|
|
|
sleep(2000);
|
|
|
|
|
click("文字配图");
|
|
|
|
|
sleep(1000);
|
|
|
|
|
click(535,1325);
|
|
|
|
|
sleep(1000);
|
|
|
|
|
setText("Hello, Auto.js!");
|
|
|
|
|
click("生成");
|
|
|
|
|
sleep(5000);
|
|
|
|
|
click("确认");
|
|
|
|
|
sleep(1000);
|
|
|
|
|
click("发布笔记");
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 功能3按钮事件
|
|
|
|
|
window.btn3.setOnTouchListener(function (view, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_UP) {
|
|
|
|
|
toast("功能3被点击");
|
|
|
|
|
threads.start(function() {
|
|
|
|
|
// 设置屏幕分辨率
|
|
|
|
|
setScreenMetrics(1080, 1920);
|
|
|
|
|
|
|
|
|
|
// 请求悬浮窗权限和无障碍服务
|
|
|
|
|
if (!floaty.checkPermission()) {
|
|
|
|
|
floaty.requestPermission();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!auto.service) {
|
|
|
|
|
toast("请开启无障碍服务");
|
|
|
|
|
auto.waitFor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var 悬块 = function (window, view) {
|
|
|
|
|
if (!window || !view) {
|
|
|
|
|
throw "缺参数";
|
|
|
|
|
}
|
|
|
|
|
this.x = 0, this.y = 0; // 记录触摸坐标
|
|
|
|
|
this.windowX, this.windowY; // 记录悬浮窗位置
|
|
|
|
|
this.downTime = 500; // 长按时间
|
|
|
|
|
this.Timeout = 0; // 定时器 ID
|
|
|
|
|
|
|
|
|
|
this.Click = function () { };
|
|
|
|
|
this.LongClick = function () { };
|
|
|
|
|
|
|
|
|
|
this.setClick = function (fun) {
|
|
|
|
|
if (typeof fun == "function") {
|
|
|
|
|
this.Click = fun;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
this.setLongClick = function (fun, ji) {
|
|
|
|
|
if (typeof fun == "function") {
|
|
|
|
|
this.LongClick = fun;
|
|
|
|
|
if (parseInt(ji) <= 1000) {
|
|
|
|
|
this.downTime = parseInt(ji);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
view.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
|
|
|
|
|
switch (event.getAction()) {
|
|
|
|
|
case event.ACTION_DOWN:
|
|
|
|
|
this.x = event.getRawX();
|
|
|
|
|
this.y = event.getRawY();
|
|
|
|
|
this.windowX = window.getX();
|
|
|
|
|
this.windowY = window.getY();
|
|
|
|
|
this.Timeout = setTimeout(() => {
|
|
|
|
|
this.LongClick();
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
}, this.downTime);
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_MOVE:
|
|
|
|
|
if (Math.abs(event.getRawY() - this.y) > 5 && Math.abs(event.getRawX() - this.x) > 5) {
|
|
|
|
|
if (this.Timeout) {
|
|
|
|
|
clearTimeout(this.Timeout);
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
window.setPosition(this.windowX + (event.getRawX() - this.x), this.windowY + (event.getRawY() - this.y));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_UP:
|
|
|
|
|
if (this.Timeout) {
|
|
|
|
|
clearTimeout(this.Timeout);
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
this.Click();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
// 创建简化版的悬浮窗UI
|
|
|
|
|
var window = floaty.window(
|
|
|
|
|
<frame>
|
|
|
|
|
<vertical>
|
|
|
|
|
{/* <button id="start" text="开始" w="*" /> */}
|
|
|
|
|
<button id="stop" text="停止" w="*" />
|
|
|
|
|
</vertical>
|
|
|
|
|
</frame>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var bd = new 悬块(window, window.stop);
|
|
|
|
|
bd.setClick(() => {
|
|
|
|
|
isLiking = false; // 停止点赞
|
|
|
|
|
window.close(); // 关闭悬浮窗
|
|
|
|
|
toast("程序已结束"); // 提示信息
|
|
|
|
|
sleep(1000);
|
|
|
|
|
exit(); // 结束脚本
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runAutomation();
|
|
|
|
|
|
|
|
|
|
// 自动化主功能
|
|
|
|
|
function runAutomation() {
|
|
|
|
|
launchApp("小红书");
|
|
|
|
|
sleep(3000);
|
|
|
|
|
enterVideo();
|
|
|
|
|
while(true){
|
|
|
|
|
sleep(2000);
|
|
|
|
|
// 点赞
|
|
|
|
|
var count= 2;
|
|
|
|
|
while(count){
|
|
|
|
|
click(500,800);
|
|
|
|
|
count= count-1;
|
|
|
|
|
}
|
|
|
|
|
sleep(2000);
|
|
|
|
|
// 关注
|
|
|
|
|
click("关注");
|
|
|
|
|
sleep(1000);
|
|
|
|
|
//滑屏
|
|
|
|
|
swipe(500, 1500, 500, 300, 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 进入小红书直播
|
|
|
|
|
function enterVideo(){
|
|
|
|
|
|
|
|
|
|
swipe(500, 1000, 500, 1100, 500);
|
|
|
|
|
|
|
|
|
|
// 等待滑动动画完成,这里等待500毫秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(1000);
|
|
|
|
|
|
|
|
|
|
click("直播");
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
|
|
|
|
|
|
click(200, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
//功能4事件
|
|
|
|
|
window.btn4.setOnTouchListener(function (view, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_UP) {
|
|
|
|
|
toast("功能4被点击");
|
|
|
|
|
threads.start(function() {
|
|
|
|
|
// 定义悬浮窗控制模块,命名为(悬块)
|
|
|
|
|
var 悬块 = function (window, view) {
|
|
|
|
|
if (!window || !view) {
|
|
|
|
|
throw "缺参数";
|
|
|
|
|
}
|
|
|
|
|
this.x = 0, this.y = 0; // 记录触摸坐标
|
|
|
|
|
this.windowX, this.windowY; // 记录悬浮窗位置
|
|
|
|
|
this.downTime = 500; // 长按时间
|
|
|
|
|
this.Timeout = 0; // 定时器 ID
|
|
|
|
|
|
|
|
|
|
this.Click = function () { };
|
|
|
|
|
this.LongClick = function () { };
|
|
|
|
|
|
|
|
|
|
this.setClick = function (fun) {
|
|
|
|
|
if (typeof fun == "function") {
|
|
|
|
|
this.Click = fun;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
this.setLongClick = function (fun, ji) {
|
|
|
|
|
if (typeof fun == "function") {
|
|
|
|
|
this.LongClick = fun;
|
|
|
|
|
if (parseInt(ji) <= 1000) {
|
|
|
|
|
this.downTime = parseInt(ji);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
view.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
|
|
|
|
|
switch (event.getAction()) {
|
|
|
|
|
case event.ACTION_DOWN:
|
|
|
|
|
this.x = event.getRawX();
|
|
|
|
|
this.y = event.getRawY();
|
|
|
|
|
this.windowX = window.getX();
|
|
|
|
|
this.windowY = window.getY();
|
|
|
|
|
this.Timeout = setTimeout(() => {
|
|
|
|
|
this.LongClick();
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
}, this.downTime);
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_MOVE:
|
|
|
|
|
if (Math.abs(event.getRawY() - this.y) > 5 && Math.abs(event.getRawX() - this.x) > 5) {
|
|
|
|
|
if (this.Timeout) {
|
|
|
|
|
clearTimeout(this.Timeout);
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
window.setPosition(this.windowX + (event.getRawX() - this.x), this.windowY + (event.getRawY() - this.y));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
case event.ACTION_UP:
|
|
|
|
|
if (this.Timeout) {
|
|
|
|
|
clearTimeout(this.Timeout);
|
|
|
|
|
this.Timeout = 0;
|
|
|
|
|
this.Click();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
// 进入小红书并进行操作
|
|
|
|
|
function autoLikeInLiveRoom() {
|
|
|
|
|
launchApp("小红书");
|
|
|
|
|
sleep(3000); // 等待小红书启动完成
|
|
|
|
|
|
|
|
|
|
// 执行下滑操作
|
|
|
|
|
swipe(500, 1000, 500, 1100, 500);
|
|
|
|
|
sleep(500); // 等待滑动动画完成
|
|
|
|
|
|
|
|
|
|
click('直播'); // 点击直播按钮
|
|
|
|
|
sleep(1000); // 等待加载
|
|
|
|
|
click(200, 1000); // 进入直播间
|
|
|
|
|
}
|
|
|
|
|
// 创建并生成一个悬浮窗
|
|
|
|
|
var window = floaty.window(
|
|
|
|
|
<vertical bg="#2196F3">
|
|
|
|
|
<button id="but" w="300px" h="150px" text="停止点赞" />
|
|
|
|
|
<button id="end" w="300px" h="150px" text="结束程序" />
|
|
|
|
|
<text text="点赞速度: " />
|
|
|
|
|
<seekbar id="speedControl" max="10" progress="2" />
|
|
|
|
|
<text id="speedValue" text="2000ms" />
|
|
|
|
|
</vertical>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 设置点赞速度变量
|
|
|
|
|
let likeInterval = 2000; // 默认点赞间隔(毫秒)
|
|
|
|
|
let isLiking = true; // 是否正在点赞
|
|
|
|
|
// 双击屏幕中间的函数
|
|
|
|
|
function doubleClickScreenCenter() {
|
|
|
|
|
// let width = device.width;
|
|
|
|
|
// let height = device.height;
|
|
|
|
|
// let centerX = width / 2;
|
|
|
|
|
// let centerY = height / 2;
|
|
|
|
|
|
|
|
|
|
click(535, 1250); // 第一次点击
|
|
|
|
|
sleep(100); // 等待100毫秒
|
|
|
|
|
click(535, 1250); // 第二次点击
|
|
|
|
|
}
|
|
|
|
|
// 启动自动点赞的循环
|
|
|
|
|
function startAutoLiking() {
|
|
|
|
|
while (isLiking) {
|
|
|
|
|
doubleClickScreenCenter(); // 执行点赞操作
|
|
|
|
|
sleep(likeInterval); // 根据设置的点赞速度等待
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 实时更新点赞速度
|
|
|
|
|
window.speedControl.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener({
|
|
|
|
|
onProgressChanged: function (seekBar, progress, fromUser) {
|
|
|
|
|
likeInterval = (progress + 1) * 1000; // 将进度转换为毫秒
|
|
|
|
|
window.speedValue.setText(likeInterval + "ms"); // 更新显示文本
|
|
|
|
|
},
|
|
|
|
|
onStartTrackingTouch: function (seekBar) { },
|
|
|
|
|
onStopTrackingTouch: function (seekBar) { }
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// 空运行定时器保持脚本运行中
|
|
|
|
|
setInterval(() => { }, 500);
|
|
|
|
|
|
|
|
|
|
// 创建一个新的悬浮控制模块
|
|
|
|
|
var ad = new 悬块(window, window.but);
|
|
|
|
|
var bd = new 悬块(window, window.end);
|
|
|
|
|
bd.setClick(() => {
|
|
|
|
|
isLiking = false; // 停止点赞
|
|
|
|
|
window.close(); // 关闭悬浮窗
|
|
|
|
|
toast("程序已结束"); // 提示信息
|
|
|
|
|
sleep(1000);
|
|
|
|
|
exit(); // 结束脚本
|
|
|
|
|
});
|
|
|
|
|
ad.setClick(() => {
|
|
|
|
|
log("已被点击");
|
|
|
|
|
if (isLiking) {
|
|
|
|
|
isLiking = false;
|
|
|
|
|
window.but.setText("开始点赞");
|
|
|
|
|
toast("已停止点赞");
|
|
|
|
|
} else {
|
|
|
|
|
isLiking = true;
|
|
|
|
|
window.but.setText("正在点赞...");
|
|
|
|
|
toast("开始自动点赞");
|
|
|
|
|
|
|
|
|
|
// 启动点赞循环在新线程中
|
|
|
|
|
threads.start(() => {
|
|
|
|
|
startAutoLiking();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
autoLikeInLiveRoom();
|
|
|
|
|
sleep(likeInterval);
|
|
|
|
|
startAutoLiking();
|
|
|
|
|
// 脚本备份功能
|
|
|
|
|
脚本备份();
|
|
|
|
|
|
|
|
|
|
function 脚本备份(path) {
|
|
|
|
|
path = path || "/sdcard/备份脚本";
|
|
|
|
|
var file = new java.io.File(path);
|
|
|
|
|
var fromfile = String(engines.myEngine().getSource());
|
|
|
|
|
var filename = new java.io.File(fromfile).getName();
|
|
|
|
|
if (!file.isDirectory()) {
|
|
|
|
|
if (!file.mkdirs()) {
|
|
|
|
|
log("创建文件夹失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var txt = files.read(fromfile);
|
|
|
|
|
files.write(files.join(path, filename), txt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
//功能5按钮事件
|
|
|
|
|
window.btn5.setOnTouchListener(function (view, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_UP) {
|
|
|
|
|
toast("功能5被点击");
|
|
|
|
|
threads.start(function () { // 创建新线程执行耗时操作
|
|
|
|
|
launchApp("小红书");
|
|
|
|
|
|
|
|
|
|
// 等待小红书启动完成,这里等待2秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(2000);
|
|
|
|
|
click("发现");
|
|
|
|
|
|
|
|
|
|
// 执行下滑操作,参数分别是:操作类型(滑动),起始X坐标,起始Y坐标,结束X坐标,结束Y坐标,持续时间
|
|
|
|
|
swipe(500, 1000, 500, 1100, 500);
|
|
|
|
|
|
|
|
|
|
// 等待滑动动画完成,这里等待500毫秒,具体时间可能需要根据实际情况调整
|
|
|
|
|
sleep(500);
|
|
|
|
|
|
|
|
|
|
click("直播");
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
|
|
|
|
|
|
click(800, 1000);
|
|
|
|
|
//2 点赞悬浮窗
|
|
|
|
|
var window = floaty.window(
|
|
|
|
|
<vertical>
|
|
|
|
|
<input id="input3" hint="请输入评论" textSize="40sp" focusable="true" />
|
|
|
|
|
<input id="input4" hint="评论次数" textSize="40sp" focusable="true" />
|
|
|
|
|
<button id="reBtn" text="随机评论" />
|
|
|
|
|
<button id="remarkBtn" text="动态评论" />
|
|
|
|
|
<button id="closeBtn" text="关闭悬浮窗" />
|
|
|
|
|
</vertical>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var s1 = 0;
|
|
|
|
|
var s2 = 0;
|
|
|
|
|
var remarkCounter = 3;
|
|
|
|
|
var commentText;
|
|
|
|
|
var List = ["666", "好可爱", "主播加油", "做的好棒", "太强了", "感谢主播!", "看得我心动", "收藏了", "牛逼"]; // 正能量语录
|
|
|
|
|
|
|
|
|
|
window.setPosition(device.width / 2 + 50, 50);
|
|
|
|
|
|
|
|
|
|
toast("长按确定键可调整位置");
|
|
|
|
|
|
|
|
|
|
window.input3.on("key", function (keyCode, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
event.consumed = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.input3.on("touch_down", () => {
|
|
|
|
|
window.requestFocus();
|
|
|
|
|
window.input3.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.input4.on("key", function (keyCode, event) {
|
|
|
|
|
if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
event.consumed = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.input4.on("touch_down", () => {
|
|
|
|
|
window.requestFocus();
|
|
|
|
|
window.input4.requestFocus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.remarkBtn.on("click", () => {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
inputContent = window.input3.getText();
|
|
|
|
|
remarkCounter = window.input4.getText();
|
|
|
|
|
if (inputContent == "") inputContent = "666";
|
|
|
|
|
if (remarkCounter < 1) remarkCounter = 1;
|
|
|
|
|
commentText = inputContent; // 设置评论的文本内容
|
|
|
|
|
log(commentText);
|
|
|
|
|
s1 = 1;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.reBtn.on("click", () => {
|
|
|
|
|
window.disableFocus();
|
|
|
|
|
remarkCounter = window.input4.getText();
|
|
|
|
|
if (remarkCounter < 1) remarkCounter = 1;
|
|
|
|
|
s2 = 1;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.closeBtn.on("click", () => {
|
|
|
|
|
window.close();
|
|
|
|
|
exit();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
if (s1 == 1) {
|
|
|
|
|
var liveTab = text("说点什么…").findOne();
|
|
|
|
|
click(liveTab.bounds().centerX(), liveTab.bounds().centerY());
|
|
|
|
|
s1 = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (s1 == 2) {
|
|
|
|
|
setText(commentText);
|
|
|
|
|
s1 = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (s1 == 3) {
|
|
|
|
|
var sendButton = text("发送").findOne();
|
|
|
|
|
click(sendButton.bounds().centerX(), sendButton.bounds().centerY());
|
|
|
|
|
s1 = 1;
|
|
|
|
|
remarkCounter--;
|
|
|
|
|
if (remarkCounter == 0) s1 = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (s2 == 1) {
|
|
|
|
|
var liveTab = text("说点什么…").findOne();
|
|
|
|
|
click(liveTab.bounds().centerX(), liveTab.bounds().centerY());
|
|
|
|
|
s2 = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (s2 == 2) {
|
|
|
|
|
var rand = Math.floor(Math.random() * List.length);
|
|
|
|
|
setText(List[rand]);
|
|
|
|
|
s2 = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (s2 == 3) {
|
|
|
|
|
var sendButton = text("发送").findOne();
|
|
|
|
|
click(sendButton.bounds().centerX(), sendButton.bounds().centerY());
|
|
|
|
|
s2 = 1;
|
|
|
|
|
remarkCounter--;
|
|
|
|
|
if (remarkCounter == 0) s2 = 0;
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|