#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.ico