pToken := Gdip_Startup() pBitmap := Gdip_CreateBitmapFromFile("image.png") if !Gdip_PixelSearch(pBitmap, ARGB := 0xff0118d9, x, y) MsgBox, Pixel %ARGB% found at (%x%, %y%) else MsgBox, Pixel %ARGB% not found Gdip_DisposeImage(pBitmap) Gdip_Shutdown(pToken) return ;##################################################################################### Gdip_PixelSearch(pBitmap, ARGB, ByRef x, ByRef y) { static _PixelSearch if !_PixelSearch { MCode_PixelSearch := "8B44241099535583E2035603C233F6C1F80239742418577E388B7C24148B6C24248B5424188D1C85000000008D64240033C085" . "D27E108BCF3929743183C00183C1043BC27CF283C60103FB3B74241C7CDF8B4424288B4C242C5F5EC700FFFFFFFF5DC701FFFFFFFF83C8FF5BC38B4C2" . "4288B54242C5F890189325E5D33C05BC3" VarSetCapacity(_PixelSearch, StrLen(MCode_PixelSearch)//2) Loop % StrLen(MCode_PixelSearch)//2 ;% NumPut("0x" SubStr(MCode_PixelSearch, (2*A_Index)-1, 2), _PixelSearch, A_Index-1, "char") } Gdip_GetImageDimensions(pBitmap, Width, Height) if !(Width && Height) return -1 if (E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)) return -2 x := y := 0 E := DllCall(&_PixelSearch, "uint", Scan01, "int", Width, "int", Height, "int", Stride1, "uint", ARGB, "int*", x, "int*", y) Gdip_UnlockBits(pBitmap, BitmapData1) return (E = "") ? -3 : E }
Here is the c++
int Gdip_PixelSearch(unsigned int * HayStack, int w, int h, int Stride, int ARGB, int * x, int * y) { int offset = Stride/4; for (int y1 = 0; y1 < h; ++y1) { for (int x1 = 0; x1 < w; ++x1) { if (HayStack[x1+(y1*offset)] == ARGB) { x[0] = x1; y[0] = y1; return 0; } } } x[0] = -1; y[0] = -1; return -1; }