It worked very well during my tests.
function FindFlagEx2(var X, Y: Integer): Boolean;
var
i, Hi, W, H, MapB,
KMTarget, ITarget : Integer;
TPA: TPointArray;
begin
MapB := BitmapFromClient(MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
for i := 0 to Hi do
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = 6381921) then
begin
Result := True;
X := TPA[i].x + MMX1;
Y := TPA[i].y + MMY1;
Break;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;
Edit: New dots function too(its 1 ms faster :0 )
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
MapB, KMTarget, ITarget, W, H,
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
MapB := BitmapFromClient(x1, y1, x2, y2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
C := 0;
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
SetLength(Result, Hi + 1);
for I := 0 to Hi do
begin
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = Dif) then
begin
Result[C] := Point(TPA[I].x + x1, TPA[i].y + y1 - 2);
Inc(C);
end;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
SetLength(Result, C);
end;