Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows服务在Python中占据屏幕_Python_Windows_Python Imaging Library - Fatal编程技术网

Windows服务在Python中占据屏幕

Windows服务在Python中占据屏幕,python,windows,python-imaging-library,Python,Windows,Python Imaging Library,我有一个作为Windows服务运行的Python脚本,它定期截图。我把它当作一个简单的Python脚本,但现在我已经把它变成了一个服务,它不再工作了。我在Windows事件查看器中获得此输出: The instance's SvcRun() method failed Traceback (most recent call last): File "C:\Python27\lib\site-packages\win32\lib\win32serviceutil.py", line 835, i

我有一个作为Windows服务运行的Python脚本,它定期截图。我把它当作一个简单的Python脚本,但现在我已经把它变成了一个服务,它不再工作了。我在Windows事件查看器中获得此输出:

The instance's SvcRun() method failed 
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\win32\lib\win32serviceutil.py", line 835, in SvcRun
    self.SvcDoRun()
File "D:\Malcolm\Dropbox\code\ambihue\ambiservice.py", line 58, in SvcDoRun
    r, g, b = ambihue.getAverageScreenColor()
File "D:\Malcolm\Dropbox\code\ambihue\ambihue.py", line 21, in getAverageScreenColor
    screen = ImageGrab.grab()
File "C:\Python27\lib\site-packages\PIL\ImageGrab.py", line 47, in grab
    size, data = grabber()
IOError: screen grab failed 
%2: %3
以下是我获得屏幕的方式:

screen = ImageGrab.grab()
关于让我的服务成功进入屏幕有什么建议吗?或者你有没有其他的抓取屏幕的解决方案?我现在正在使用PIL

我的全部代码都在这里:

不久前我问了一个类似的问题:见