I am making a screen capture program with python. My current problem is PIL.ImageGrab.grab() gives me the same output as 2 seconds later. For instance, for I think I am not being clear, in the following program, almost all the images are the same, have the same Image.tostring() value, even though I was moving my screen during the time the PIL.ImageGrab.grab loop was executing.
>>> from PIL.ImageGrab import grab
>>> l = []
>>> import time
>>> for a in l:
l.append(grab())
time.sleep(0.01)
>>> for a in range(0, 30):
l.append(grab())
time.sleep(0.01)
>>> b = []
>>> for a in l:
b.append(a.tostring())
>>> len(b)
30
>>> del l
>>> last = []
>>> a = 0
>>> a = -1
>>> last = ""
>>> same = -1
>>> for pic in b:
if b == last:
same = same + 1
last = b
>>> same
28
>>>
This is a problem, as all the images are the same but 1. 1 out of 30 is different. That would make for a absolutly horrable quality video. Please, tell me if there is any better quality alternative to PIL.ImageGrab.grab(). I need to capture the whole screen. Thanks!
EDIT:
So far, it looks like the best alternative is to use pywin32. I am using that for now, but it is very slow. I don't really care about compatability, as for now this project is personal. Every time I work out the frame rate of the program, pywin32 is so slow, it's in the negatives. Please tell me if there is a faster alternative. Thanks!
pywin32
is "very slow"? In general, it's a much thinner wrapper around the native Windows APIs than wx, Qt, or anything else. – Gidgetgie