【Demo】python脚本定时提醒喝水脚本

#from win10toast import ToastNotifier
from win10toast_persist import ToastNotifier
from apscheduler.schedulers.blocking import BlockingScheduler
import time
import win32api,win32con

'''
代码实现每天9点开始定时,下午6点结束定时;
每天9,11,13,15,17时提醒喝水;
两个list列表设置提醒内容
'''

#Path to icon
image = "D:\\DrinkReminder-main\\img\\water.ico"
start_time = time.strftime('%Y-%m-%d ',time.localtime(time.time())) + '09:00:00'
end_time = time.strftime('%Y-%m-%d ',time.localtime(time.time())) + '18:00:00'
#Define toaster
toaster = ToastNotifier()

#Let user know the program has started
toaster.show_toast("喝水提醒开始啦~~~~~~~","按时喝水哦!!!.",image, None)
remind_txt1 = ['工作前喝一杯水', '工作间隙喝一杯水', '午餐后一小时一杯水', '下午喝一杯水', '快下班啦~~~']
remind_txt2 = ['镇定精神,努力工作', ',放松情绪,补充水分', '促进消化保持身材', '消除疲劳,振奋精神', '喝水增加饱腹感']
def reminder():
    hour = time.strftime("%H", time.localtime())
    if hour =='09':
        toaster.show_toast(remind_txt1[0], remind_txt2[0], image, None)
        win32api.MessageBox(0, remind_txt1[0],remind_txt2[0], win32con.MB_OK)
    elif hour =='11':
        toaster.show_toast(remind_txt1[1], remind_txt2[1], image, None)
        win32api.MessageBox(0, remind_txt1[1],remind_txt2[1], win32con.MB_OK)
    elif hour == '13':
        toaster.show_toast(remind_txt1[2], remind_txt2[2], image, None)
        win32api.MessageBox(0, remind_txt1[2],remind_txt2[2], win32con.MB_OK)
    elif hour == '15':
        toaster.show_toast(remind_txt1[3], remind_txt2[3], image, None)
        win32api.MessageBox(0, remind_txt1[3],remind_txt2[3], win32con.MB_OK)
    elif hour == '17':
        toaster.show_toast(remind_txt1[4], remind_txt2[4], image, None)
        win32api.MessageBox(0, remind_txt1[4],remind_txt2[4], win32con.MB_OK)



#Setup Scheduler
scheduler = BlockingScheduler()
#9;11;13;15;17提醒
scheduler.add_job(reminder, 'interval', minutes=1,start_date=start_time, end_date=end_time)
scheduler.start()

water.icowater.ico

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

liiiiiiiiiiiiike

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

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

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

打赏作者

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

抵扣说明:

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

余额充值