There is an online calendar of events. I will fetch the names, dates and times of these events. I then want to use python to pass these events to Windows Task Scheduler (running Win 10), then have the script exit. For each task, at the appropriate time, I want Task Scheduler to generate a Windows toast notification. Once the toast notification is generated, the task is finished, and I'd want to remove the completed task from Task Scheduler.

Is this the most efficient way, using python (and not keeping a script running all day, as these events are hours apart), to fetch events from an online calendar and generate toast notifications?

If so, can you give me a general outline of how to do this?

I've played around with ChatGPT and Bard, and they've sent me down endless rabbit holes, with many hallucinations about properties that don't exist for various objects. So now I'm wondering if the basic concept of using python to schedule several tasks in one shot, then exit, and have Task Scheduler generate toast notifications, and then delete the completed tasks from Task Scheduler, is even feasible. Or if there are superior methods to accomplish my goal?

1

There are 1 best solutions below

0
jub On BEST ANSWER

For anyone who comes across this while trying to solve a similar problem, here's what I ended up doing.

Created a python script uses win32com.client library, and uses that library to schedule tasks. The action each task takes is to launch a powershell script at the scheduled time and pass to the script the notification message. The powershell script uses the BurntToast module to generate toast notifications.

Still figuring out how to delete tasks. Currently I'm creating a deletion task that will delete its corresponding (by name of task) task x minutes after scheduled time. But that creates a deletion task that itself isn't self-deleting. But by reusing task names (task name is only see in Task Scheduler, not in the toast notifications), this process keeps the number of deletion tasks in Task Scheduler to a minimum.

Hope this helps!