Oie, as if the battle for the best text editor is not enough ...



Well, can you run a test for me?

Use the best for-equivalent and run the code below,


instead of 1024*768,  scale to 800*600 , just so the window you are screen
shotting from is small enough.







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()

pix = image.load()
print pix[x, y]



x = 0
y = 0
for x in xrange(1,1024,1):
 for y in xrange(1,768,1):
   rgb = pix[x,y]



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
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to