I understand that for some things it would be better to write certain things in C++, but I\'d really like to be able to do this in AHK:
I want to be able to retrieve
To reduce delays between commands to a minimum you should also use SetBatchLines, -1
. This alone can give you a significant performance boost.
I think you have already figured out the rest.
But in case anyone else stumbles across this question. Here is how you can do it with GDI+:
SetBatchLines, -1
#Include Gdip.ahk
pToken := Gdip_Startup()
; Screen area ("X|Y|Width|Height")
pBitmap := Gdip_BitmapFromScreen("500|600|300|100")
; Read RGB color from pixel x290 y65
ARGB := Gdip_GetPixel( pBitmap, 290, 65 )
pixelColor := ARGBtoRGB( ARGB )
MsgBox, % pixelColor
; Read RGB color from pixel x167 y90
ARGB := Gdip_GetPixel( pBitmap, 167, 90 )
pixelColor := ARGBtoRGB( ARGB )
MsgBox, % pixelColor
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
ARGBtoRGB( ARGB ) {
VarSetCapacity( RGB,6,0 )
DllCall( "msvcrt.dll\sprintf", Str,RGB, Str,"%06X", UInt,ARGB<<8 )
Return "0x" RGB
}
The code is mostly what I already posted in another answer right here.