AHK website Chinese forum Get the color function:
GetColor (); under Mouse color
GetColor (7,7); Specifies the color of the coordinates
GetColor (7,7,7,7); Specifies a range that returns a level two object with the height axis.
Overcome the following disadvantages of the built-in color-fetching command:
The delay is severe under the frosted glass.
The batch color extraction efficiency is low.
GetColor (x:="", y:="", w:=1, h:=1) {; Take colorStaticPT PT?"":(Dllcall ("GetModuleHandle","Str","Gdiplus","uptr"), Varsetcapacity (i,a_ptrsize=8? -: -,0), I:=CHR (1), Dllcall ("Gdiplus\gdiplusstartup","uptr*"Pt"uptr", &i,"uptr",0)), (x="")? GetCursorPos (x, y):"", D:=dllcall ("CreateCompatibleDC","Uint",0), varsetcapacity (b, +,0), Numput (W,b,4,"UINT"), Numput (H,b,8,"UINT"), Numput ( +B0,"UINT"), Numput (1B A,"ushort"), Numput (0B -,"uInt"), Numput ( +B -,"ushort"), M:=dllcall ("createdibsection","uptr"D"uptr", &b,"UINT",0,"uptr*",0,"uptr",0,"UINT",0,"uptr"), O:=dllcall ("SelectObject","uptr"D"uptr", M), Dllcall ("BitBlt","uptr"D"int",0,"int",0,"int"W"int"H"uptr", I:=dllcall ("GetDC","uptr",0),"int"X"int"Y"UINT",0x00cc0020), Dllcall ("ReleaseDC","uptr",0,"uptr", i), Dllcall ("Gdiplus\gdipcreatebitmapfromhbitmap","uptr"M"uptr", Palette,"uptr*", p), Dllcall ("SelectObject","uptr"D"uptr", O), Dllcall ("DeleteObject","uptr", M), Dllcall ("DeleteDC","uptr", i), Dllcall ("DeleteDC","uptr", d), varsetcapacity (T, -), Numput (0T0,"UINT"), Numput (0T4,"UINT"), Numput (W,t,8,"UINT"), Numput (H,t, A,"UINT"), varsetcapacity (b, -+2*a_ptrsize,0), Dllcall ("gdiplus\gdipbitmaplockbits","uptr"P"uptr", &t,"UINT",3,"int",0x26200a,"uptr",&b), E:= Numget (b,8,"Int"), U:=numget (b, -,"uptr"), r:=A_formatinteger Setformat,integerfast,hexif(w>1or h>1) {f:=[] Loop,%h%{F[a_index]:=j:=[],s:= (a_index-1)*e Loop,%w%J[a_index]:=numget (u+0, ((a_index-1)*4) +s,"UInt") &0x00ffffff "" } } ElseF:=numget (u+0,0,"UInt") &0x00ffffff ""Setformat,integerfast,%r%Dllcall ("gdiplus\gdipbitmapunlockbits","uptr"P"uptr",0) Dllcall ("Gdiplus\gdipdisposeimage","UINT", p)returnF}
Original address: http://ahkscript.org/boards/viewtopic.php?f=28&t=5023
[Go] Custom color-fetching function