I have a Python script running as a Windows service that takes screenshots regularly. I had this working as a simple Python script, but now that I've turned it into a service it no longer functions. I get this output in Windows Event Viewer:
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
Here's how I get the screen:
screen = ImageGrab.grab()
Any suggestions on getting my service to successfully get the screen? Or do you have any alternate solutions for grabbing the screen - I'm using PIL right now.
My entire code is up here: https://github.com/crummy/ambihue