-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetNotification.py
33 lines (25 loc) · 936 Bytes
/
setNotification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
from datetime import datetime
from win11toast import toast
import schedule
def show_toast(title, message,link):
print(link)
toast(title, message, audio='ms-winsoundevent:Notification.Looping.Alarm',on_click=link,button = "Dismiss")
def schedule_toast(title, message, target_time, link):
def job():
show_toast(title, message, link)
schedule_time = target_time.strftime("%H:%M")
schedule.every().day.at(schedule_time).do(job)
# Example usage
def setNotification (title, message, link, hours, minutes):
title = title
message = message
link = link
# Set the target time to 5:22 PM
target_time = datetime.strptime(f"{hours}:{minutes}", "%H:%M")
# Schedule the toast notification
schedule_toast(title, message, target_time, link)
# Keep the script running to check for scheduled tasks
while True:
schedule.run_pending()
time.sleep(1)