I need to get the color of some pixels on the screen or from the active window, and I need to do so quickly. I\'ve tried using win32gui and ctypes/
Disabling Windows Desktop Composition speeds pixel up reading A LOT.
Computer -> Properties -> Advanced system settings -> Performance -> desktop composition [ ] (warning this disables Windows's transparency effects)
Python 2.7 (Should be same for 3.x)
win32gui.GetPixel() #1.75s => 20ms
windll.gdi32.GetPixel() #1.75s => 3ms (fastest)
image.getpixel() # 0.1s => 50ms
px[] # 0.1s => 50ms
AutoIt for comparison
$timer = TimerInit()
For $x = 0 To 100 Step 10
For $y = 0 To 100 Step 10
PixelGetColor($x,$y) ;slow => 1ms
Next
Next
ConsoleWrite("Time: " & TimerDiff($timer)/1000 & @CRLF)