来自 Python 服务的警报弹出窗口 [英] Alert Popups from service in Python

查看:56
本文介绍了来自 Python 服务的警报弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 win32api.MessageBox 来发出警报,这适用于从交互式提示和正常执行的代码运行的应用程序,但是当我在触发 MessageBox 时构建 Python 服务时,我可以听到哔"声,但是框不显示.是否可以显示来自服务的警报?

I have been using win32api.MessageBox to do alerts, and this works for apps running from the interactive prompt and normally executed code, however when I built a Python service when a MessageBox is triggered I can hear the 'beep' but the box does not display. Is it possible to display alerts from services?

推荐答案

不,Windows 服务在完全独立的隐藏桌面上运行,无法访问登录用户的桌面.从服务开发者的角度来看,这是没有办法解决的.

No, Windows services run on a completely separate hidden desktop and have no access to the logged-on user's desktop. There is no way around this from a service developer's perspective.

在以前的 Windows 版本中,可以将服务标记为允许与用户桌面交互",但在 XP 或 Vista 中删除了此选项(我忘了是哪个).现在,服务无法与用户桌面交互.

In previous versions of Windows, it was possible for a service to be marked as "allowed to interact with the user desktop", but this option was removed in XP or Vista (I forget which). Now, services cannot interact with the user desktop.

您的问题的一种解决方案可能是让桌面应用程序通过某种 IPC 方法与服务进行通信.当服务想要提醒用户某种情况时,它会通知桌面应用程序,然后桌面应用程序会显示一个常规消息框.

One solution to your problem might be to have a desktop application that communicates with the service through some IPC method. When the service wants to alert the user of some condition, it would notify the desktop application which would then display a regular message box.

这篇关于来自 Python 服务的警报弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆