从 Windows 10 通知触发 python 中的脚本

Trigger a script in python from a Windows 10 Notification

我想在 Windows 10 收到通知时执行 Python 脚本。然后,根据通知,我将能够执行不同的任务。例如:如果我收到来自 Slack 的通知,我可以使连接到 PC 的 Arduino 上的 LED 灯闪烁。

我看到 Microsoft 有一个 UserNotificationListener class 作为其 UWP api 的一部分,以防我用 C# 编写应用程序,但是我可以从 Python 还是来自 Powershell?

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

据我所知Python 和 UWP 技术无法在它们之间调用任何 API。所以我认为这是不可能的。

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

然而,我们可以从 UWP 本身做到这一点。

请查看此线程:Launch powershell script from UWP app with FullTrustProcessLauncher class。正如该线程的标题所述,desktopbridge 技术支持从 UWP 技术调用普通 win32 应用程序的完全信任访问。因此,当您创建自己的侦听通知的应用程序时,如果收到新通知,您可以在事件中添加一个调用,然后执行您的 powershell 脚本。调用过程由您的 win32 exe 处理。我认为这确实符合您的要求。