, , , , Python pywin32 (, ). " " numpy whatnot.
, 5 (6 ):
import win32ui
window_name = "Target Window Name"
wd = win32ui.FindWindow(None, window_name)
dc = wd.GetWindowDC()
j = dc.GetPixel (60,20)
print j
dc.DeleteDC()
. (COLORREF) , ( , RGB hex) , , , !
, ( Python build CPython i7 4770k):
( ):
import ImageGrab, time
box = (0,0,100,100) #100 x 100 square box to capture
pixel = (60,20) #pixel coordinates (must be within the box boundaries)
t1 = time.time()
count = 0
while count < 1000:
s = ImageGrab.grab(box) #grabs the image area
h = s.getpixel(pixel) #gets pixel RGB value
count += 1
t2 = time.time()
tf = t2-t1
it_per_sec = int(count/tf)
print (str(it_per_sec) + " iterations per second")
29 . , .
, BenjaminGolder ctypes:
from ctypes import windll
import time
dc= windll.user32.GetDC(0)
count = 0
t1 = time.time()
while count < 1000:
a= windll.gdi32.GetPixel(dc,x,y)
count += 1
t2 = time.time()
tf = t2-t1
print int(count/tf)
54 . 86%, , .
, , :
name = "Python 2.7.6 Shell"
w = win32ui.FindWindow( None, name )
t1 = time.time()
count = 0
while count < 1000:
dc = w.GetWindowDC()
dc.GetPixel (60,20)
dc.DeleteDC()
count +=1
t2 = time.time()
tf = t2-t1
it_per_sec = int(count/tf)
print (str(it_per_sec) + " iterations per second")
16000 script. , 16000. 2 , , 29600%.
, count + = 1 .
100 ., 1000 , - , 14-16 . . 7-8 , , , ... , .
, ! , , . , Python .