Alert Popups from service in Python

时间秒杀一切 提交于 2019-12-20 02:08:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/204062/alert-popups-from-service-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!