SCAR Code:
Procedure UpdateIn(Var Color: Integer; x1, y1, x2, y2: Integer);
Var
OldColor, tmpHandle, bmp, L, I, TempTol, NewC, T, W, H, MaxTol, CTS: Integer;
TPA: TPointArray;
Begin
//If Not LoggedIn Then Exit;
CTS := GetColorToleranceSpeed;
If Not CTS = 2 Then ColorToleranceSpeed(2);
MaxTol := Round(Distance(x1, y1, x2, y2) * 1.5);
SetColorSpeed2Modifiers(0.3, Distance(x1, y1, x2, y2) * 0.02);
OldColor := Color;
tmpHandle := GetClientWindowHandle;
bmp := BitmapFromString2(False, '');
CopyClientToBitmap(bmp, x1, y1, x2, y2);
SetTargetBitmap(bmp);
GetBitmapSize(bmp, W, H);
FindColorsTolerance(TPA, OldColor, 0, 0, W, H, MaxTol);
Try
TempTol := iAbs(Color - GetColor(TPA[High(TPA)].x, TPA[High(TPA)].y));
Except
Writeln('No instances of the color Color found.');
SetClientWindowHandle(tmpHandle);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
End;
L := High(TPA);
For I := 0 To L Do
Begin
T := iAbs(Color - GetColor(TPA[i].x, TPA[i].y));
If T < TempTol Then
Begin
TempTol := T;
NewC := I;
End;
End;
If NewC <> 0 Then
Begin
Color := GetColor(TPA[NewC].x, TPA[NewC].y);
If FindColor(W, H, Color, x1, y1, x2, y2) Then
MoveMouse(W, H);
Writeln('---<UpdateIn>---');
Writeln('Old: '+IntToStr(OldColor));
Writeln('New: '+IntToStr(Color));
Writeln('----------------');
End Else
Begin
Writeln('Color could not be updated.');
End;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
SetClientWindowHandle(tmpHandle);
End;