Tip: 随便练练,怕以后不会用了。熟能生巧
Time:2024年12月24日11:44:21
By: MemroyErHero
Code: 定时开关QQ音乐
function diy_toast(nr,t)
print(nr)
toast(nr,t,0,0)
sleep(t)
end
function closeApp()
home()
diy_toast("指令:回到桌面",1000)
jobs()
diy_toast("指令:召唤菜单",1000)
win_close = R():id("com.coloros.recents:id/clear_button");
find_close = find(win_close)
if find_close then
find_close:click()
diy_toast("指令:清除程序",1000)
end
end
function openApp()
musci_qq = "com.tencent.qqmusic"
runApp(musci_qq)
diy_toast("指令:打开目标程序",5000)
end
function work(diyxx,diyfz,opxx,opfz)
while true do
no = 0
while true do
local currentTime = os.date("*t")
local currentHour = tonumber(currentTime.hour)
local currentMinute = tonumber(currentTime.min)
no = no + 1
toast("运行中"..no.."...",1000,0,0)
print("当前时间:" .. currentHour.." : ".. currentMinute)
sleep(1000)
if currentHour == tonumber(diyxx) and currentMinute == tonumber(diyfz) then
print("指令:触发关闭命令")
closeApp()
diy_toast("指令: 清除程序中",1000)
for i=1,66,1 do
diy_toast("指令: 清除程序中"..i,1000)
end
break
end
end
sleep(1000)
no = 0
while true do
local currentTime = os.date("*t")
local currentHour = tonumber(currentTime.hour)
local currentMinute = tonumber(currentTime.min)
no = no + 1
toast("运行中"..no.."...",1000,0,0)
print("当前时间:" .. currentHour.." : ".. currentMinute)
sleep(1000)
if currentHour == tonumber(opxx) and currentMinute == tonumber(opfz) then
print("指令:触发开启命令")
openApp()
diy_toast("指令: 打开程序中",1000)
for i=1,66,1 do
diy_toast("指令: 打开程序中"..i,1000)
end
break
end
end
end
end
function main(diyxx,diyfz,opxx,opfz)
work(diyxx,diyfz,opxx,opfz)
end
ui={
title="QQ音乐关闭助手";
time = 60;
views={
{title ="关闭小时:",type="edit",hint="请输入小时",id="xx",mode ="text",value ="23"},
{title ="关闭分钟:",type="edit",hint="请输入分钟",id="fz",mode ="text",value ="15"},
{title ="开启小时:",type="edit",hint="请输入小时",id="ox",mode ="text",value ="13"},
{title ="开启分钟:",type="edit",hint="请输入分钟",id="of",mode ="text",value ="1"},
}
}
local ret = show( ui )
if ret then
print('用户选择了确认')
local my_hour = tonumber(xx)
local my_mintuer = tonumber(fz)
print(my_hour)
print(my_mintuer)
local my_hour2 = tonumber(ox)
local my_mintuer2 = tonumber(of)
print(my_hour2)
print(my_mintuer2)
main(my_hour,my_mintuer,my_hour2,my_mintuer2)
else
print('用户选择了取消')
diy_toast("指令:本次服务到此结束!",2000)
end