节点精灵项目实战一定时开关QQ音乐

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()
        --click(540,1620)
        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)

        --自动打开QQ音乐
        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; -- 10秒后自动选择确认
    --width = -1;
    --height = -1;
    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













评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MemroyErHero

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值