来自 Python 服务的警报弹出窗口
我一直在使用 win32api.MessageBox 来执行警报,这适用于从交互式提示运行的应用程序和正常执行的代码,但是当我构建 Python 服务时,当 MessageBox 被触发时,我可以听到“嘟嘟”声,但该框却听不到展示。 是否可以显示来自服务的警报?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,Windows 服务在完全独立的隐藏桌面上运行,并且无法访问登录用户的桌面。 从服务开发人员的角度来看,没有办法解决这个问题。
在以前版本的Windows中,服务可以被标记为“允许与用户桌面交互”,但这个选项在XP或Vista中被删除(我忘了是哪一个)。 现在,服务无法与用户桌面交互。
解决您的问题的一种方法可能是拥有一个通过某种 IPC 方法与服务进行通信的桌面应用程序。 当服务想要警告用户某些情况时,它会通知桌面应用程序,然后桌面应用程序会显示一个常规消息框。
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.
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.
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.