// 文档地址 https://docs.hamibot.com/
var floatyWin = floaty.window(
<vertical padding="4" h="260dp" layout_weight="1">
<horizontal gravity="center" marginTop="4" >
<text text="计时:" textSize="12" />
<text id="timeDisplay" textSize="12" layout_weight="1" textColor="#FF0000" />
</horizontal>
<horizontal gravity="center_vertical" marginTop="4">
<text text="密码:" textSize="12" />
<input id="pwdInput" text="" password="false" layout_weight="1" hint="支付密码" width="100dp" textSize="10" />
</horizontal>
<horizontal gravity="center_vertical" marginTop="2">
<text text="数量:" textSize="10" />
<button id="countToggleBtn" text="1" h="40"layout_weight="1" textColor="white" textSize="10" marginLeft="5" />
</horizontal>
<horizontal gravity="center" marginTop="1">
<button id="startBtn" text="开始" h="40" layout_weight="1" style="Widget.AppCompat.Button.Colored" textSize="10" />
</horizontal>
<horizontal gravity="center" id="closeBtnH" marginTop="1">
<button id="closeBtn" text="关闭" h="40" layout_weight="1" style="Widget.AppCompat.Button.Colored" textSize="10" />
</horizontal>
</vertical>
);
// 初始化变量
var selectedCount = 1;
var isRunning = true;
var isExpanded = true;
// 更新时间的函数 - 只显示时分秒
function updateTime() {
while (isRunning) {
ui.run(function() {
var now = new Date();
var timeStr = util.format("%s:%s:%s:%s",
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds());
floatyWin.timeDisplay.setText(timeStr);
});
sleep(88);
}
}
// 数量切换按钮点击事件
floatyWin.countToggleBtn.click(function() {
selectedCount = selectedCount === 1 ? 2 : 1;
floatyWin.countToggleBtn.setText(selectedCount.toString());
});
// 启动时间更新线程
threads.start(updateTime);
// 开始按钮点击事件
floatyWin.startBtn.click(function() {
var password = floatyWin.pwdInput.text();
toastLog("开始执行\n数量: " + selectedCount + "\n密码: " + password);
});
// 关闭按钮点击事件
floatyWin.closeBtn.click(function() {
isRunning = false;
floatyWin.close();
exit();
});
// 保持脚本运行
setInterval(function() {}, 500);
密码无法吊起输入框,没有反应
回答
你的悬浮窗中密码输入框无法弹出键盘,可能原因及解决方案如下:
-
密码框属性设置错误:
将password="false"
改为password="true"
(虽然你的描述是"密码"输入框,但若需要数字键盘需额外设置) -
悬浮窗触摸权限问题:
确保未调用setTouchable(false)
,若已设置请改为:floatyWin.setTouchable(true);
-
输入框焦点问题:
在创建悬浮窗后添加焦点请求:floatyWin.pwdInput.requestFocus();
-
布局层级问题:
检查是否有其他控件覆盖输入框,可临时修改背景色调试:<input ... background="#888888" />
-
兼容性处理:
在脚本开头添加:// 文档地址 https://docs.hamibot.com/
完整调试建议:
var floatyWin = floaty.window(
<vertical padding="4" h="260dp" layout_weight="1">
<horizontal gravity="center" marginTop="4">
<text text="计时:" textSize="12" />
<text id="timeDisplay" textSize="12" layout_weight="1" textColor="#FF0000" />
</horizontal>
<horizontal gravity="center_vertical" marginTop="4">
<text text="密码:" textSize="12" />
<input id="pwdInput" text="" password="true" layout_weight="1" hint="支付密码" width="100dp" textSize="10" />
</horizontal>
<!-- 其他控件保持不变 -->
</vertical>
);
// 添加焦点请求
floatyWin.pwdInput.requestFocus();
若问题仍存在,请检查设备系统权限设置,确保已开启「悬浮窗」和「无障碍服务」权限。