I ran this:
import time import ImageGrab # Part of PIL from ctypes import * # Load up the Win32 APIs we need to use. class RECT(Structure): _fields_ = [ ('left', c_ulong), ('top', c_ulong), ('right', c_ulong), ('bottom', c_ulong) ] time.sleep(2) GetForegroundWindow = windll.user32.GetForegroundWindow GetWindowRect = windll.user32.GetWindowRect # Sleep for 2 seconds - click the window you want to grab. #time.sleep(2) # Grab the foreground window's screen rectangle. rect = RECT() foreground_window = GetForegroundWindow() GetWindowRect(foreground_window, byref(rect)) image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom)) # Save the screenshot as a BMP. #image.save("c:\ee\screenshot.bmp") # Get the pixel 10 pixels along the top of the foreground window - this # will be a piece of the window border. print time.time() x = 0 y = 0 while x < 400: while y < 20: rgb = image.getpixel((10, 0)) y = y + 1 y = 0 x = x + 1 print time.time() # PIL returns colours as RGB values packed into a triple: print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2]) # This prints RGB(0, 74, 216) on my XP machine What that does is to take a screen shot and then pixelgetcolor() over 8000 (x,y) points for me it clocked at 0.08 seconds and I am trying cut it down to maybe 0.04 any hints on performance increase?
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor