python - 服务中的桌面通知

标签 python notifications windows-services desktop

我编写了一个 python 程序,它从服务器获取消息并调用 Windows 通知。

我使用 pyinstaller 将该程序变成了一个可执行的文件,该程序在作为应用运行时运行完美。

当我使用 nssm.exe 在 Windows 10 上将它变成一个服务时,该服务仍然运行良好(监听和响应服务器)但不显示通知。

我试过了

  • 允许服务在服务属性下与桌面交互 > 登录。
  • 更改注册表 HKEY_LOCAL_MACHINE>SYSTEM>CurrentControlSet>Control>Windows>NoInteractiveService = 0(False)

还有什么我可以尝试解决这个问题的吗?

编辑 - 该程序作为脚本 (.py) 和可执行文件 (.exe) 运行良好(通信和通知),问题是当可执行文件作为使用 nssm 的服务运行时不显示通知.

最佳答案

Windows 服务在后台运行,在 isolated Session 0 上.它们的 GUI 元素(托盘图标、窗口)不会显示在您的交互式桌面上。

在以前的 Windows 版本中,您可以切换到 session 0 来查看应用程序的窗口(尽管不是托盘图标)。然而,access to Session 0 has been removed in Windows 10 .

关于python - 服务中的桌面通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67264169/

相关文章:

tomcat - 多个实例 Tomcat 作为 Windows 服务

python - 如何更新 Python pip?

Python - 使用 BOM 解码 UTF-16 文件

安卓通知时间

c# - Windows 服务输出未显示在事件日志中

multithreading - 自托管 pushsharp - Events_OnNotificationSendFailure 失败 : There were not enough free threads in the ThreadPool to complete the operation

python - numpy.float64 对象不可迭代...但我不想

python - 查找数组中的最近点 - KDTree 的倒数

android - 通知: pass data

Android 通知不适用于单击/点击锁定屏幕