views:

92

answers:

1

Hi, I along with some friends are trying to do an anti cheats for a game, we chose python because it is multiplatform.

The problem is we're trying to make a screenshot of what is shown on the screen, not just the game (with OpenGL) but any windows that are open to detect programs that are superimposed on the image of the game (for example to indicate the positions of other players in online games)

We tried to use Python Imaging Library (PIL) but with the game open, taking pictures in gray, OpenGL draws the images in black and have tried other things, but nothing has worked (problems with Aero in Windows Vista / 7).

Google does not show anything about it.

Anyone know any way to make a screenshot with python in Windows 7?

from PIL import ImageGrab 
ImageGrab.grab().save('test.jpg', "JPEG")

This does not work

import Tkinter
from OpenGL.GL import *
root = Tkinter.Tk()
width = int(root.winfo_screenwidth())
height = root.winfo_screenheight()
screenshot = glReadPixels( 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE)
im = Image.frombuffer("RGBA", (width, height), screenshot, "raw", "RGBA", 0, 0)
im.save('test.jpg')

And this does not work

+1  A: 

The ImageGrab module should work on Windows 7.

http://www.pythonware.com/library/pil/handbook/imagegrab.htm

Chris G.
Im using it but just capture desktop and windows, when you open a game it Fails and the screenshots are grey
Cristian Deluxe