pythonpowershellnotificationswindows-10-universal

Trigger a script in python from a Windows 10 Notification


I would like to execute a Python script whenever I receive a notification on Windows 10. Then, based on the notification, I would be able to execute different tasks. For example: if I get a notification from Slack, I could blink a led on an Arduino connected to the PC.

I see that Microsoft has a UserNotificationListener class as part of its UWP api in case I write an app in C#, but can I access the same functionality from Python or from Powershell?


Solution

  • but can I access the same functionality from Python or from Powershell

    As far as I know Python and UWP technology cannot call any API between themselves. So I don't think this is possible.

    I would like to execute a Python script whenever I receive a notification on Windows 10

    However this is possible for us to do from UWP itself.

    Please have a look at this thread:Launch powershell script from UWP app with FullTrustProcessLauncher class. As the title of that thread mentioned, the desktopbridge technology enables full trust access for normal win32 apps to be called from UWP technology. So when you create your own app which listens to the notification, if a new notification is received, you can add a call in your event which will then execute your powershell script. The calling process is handled by your win32 exe. I think this does make sense for your requirement.