- 1 year ago
How can I get a list of the System Tray notifications in Python?
Comment
1 / 1
You can use the win10toast
module to retrieve a list of the active notifications in the Windows system tray. Here's an example:
pythonimport win10toast
def get_notifications():
toaster = win10toast.ToastNotifier()
notifications = []
for _, notification in toaster.notification_store:
notifications.append(notification.title)
return notifications
print(get_notifications())
This code will return a list of the titles of the active notifications. Note that you'll need to install the win10toast
module first using pip install win10toast
. Also note that this will only work on Windows 10 or later, as the toast notification system was introduced in Windows 10.