CODEX

Python: Windows Alert Timer

Learn how to send yourself alerts after a discrete period.

Julian Willett, MD, PhD
CodeX
Published in
2 min readFeb 24, 2021

--

Photo by Hitesh Choudhary on Unsplash

I have a lot to do, and it can be hard to keep track of my tasks. This motivated me to learn how to make use of Windows 10 notifications. In this tutorial, I will be going over how to use python to produce notifications at set times. This could be useful for an alarm function or limiting screen time, as I prefer to do when possible. I made a tutorial on this because on experimenting with different methods, it was evident that this is more complicated to figure out than you would think.

Steps:

  1. First, open up your command line by opening the search bar and typing in “cmd”

2. Install the WINRT package using the following:

pip install winrt

3. Next, open up your favourite coding program; I like to use Atom.

4. First things first, we have to import the relevant packages, which can be done with the following:

import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
import time

5. Next, we want to initialize the base variables. This can be done with the following:

notifString = """
<toast>
<visual>…

--

--

Julian Willett, MD, PhD
CodeX
Writer for

Loving husband. Physician scientist who enjoys spreading his knowledge and experiences with the world whether related to medicine, science, or his hobbies.