diff --git a/Units/MMLAddon/PSInc/Wrappers/colour.inc b/Units/MMLAddon/PSInc/Wrappers/colour.inc index 5049d68..3b2c217 100644 --- a/Units/MMLAddon/PSInc/Wrappers/colour.inc +++ b/Units/MMLAddon/PSInc/Wrappers/colour.inc @@ -1,24 +1,29 @@ -function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean; -begin - Result := CurrThread.Client.MFinder.FindColor(x, y, color, x1, y1, x2, y2); -end; - -function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; -begin - Result := CurrThread.Client.MFinder.FindColorTolerance(x, y, color, x1, y1, x2, y2, tol); -end; - -function FindColors(var TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; -begin - Result := CurrThread.Client.MFinder.FindColors(TPA, color, x1, y1, x2, y2); -end; - -procedure SetColorToleranceSpeed(cts: Integer); -begin - CurrThread.Client.MFinder.SetToleranceSpeed(cts); -end; - -function SimilarColors(Col1,Col2,Tol : integer) : boolean; -begin; - Result := CurrThread.Client.MFinder.SimilarColors(Col1,Col2,Tol); -end; +function GetColor(x,y : integer) : TColor; +begin; + Result := CurrThread.Client.MWindow.GetColor(x,y); +end; + +function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean; +begin + Result := CurrThread.Client.MFinder.FindColor(x, y, color, x1, y1, x2, y2); +end; + +function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; +begin + Result := CurrThread.Client.MFinder.FindColorTolerance(x, y, color, x1, y1, x2, y2, tol); +end; + +function FindColors(var TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; +begin + Result := CurrThread.Client.MFinder.FindColors(TPA, color, x1, y1, x2, y2); +end; + +procedure SetColorToleranceSpeed(cts: Integer); +begin + CurrThread.Client.MFinder.SetToleranceSpeed(cts); +end; + +function SimilarColors(Col1,Col2,Tol : integer) : boolean; +begin; + Result := CurrThread.Client.MFinder.SimilarColors(Col1,Col2,Tol); +end; diff --git a/Units/MMLAddon/PSInc/pscompile.inc b/Units/MMLAddon/PSInc/pscompile.inc index 48aa2ea..d22762f 100644 --- a/Units/MMLAddon/PSInc/pscompile.inc +++ b/Units/MMLAddon/PSInc/pscompile.inc @@ -7,6 +7,7 @@ Sender.Comp.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)'); Sender.AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;'); Sender.AddFunction(@psWriteln,'procedure writeln(s : string);'); +Sender.AddFunction(@GetColor,'function GetColor(x, y: Integer): Integer;'); Sender.AddFunction(@FindColor, 'function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean;'); Sender.AddFunction(@FindColorTolerance, 'function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean;'); Sender.AddFunction(@FindColors, 'function findcolors(var TPA: TPointArray; color, x1, y1, x2, y2: integer): boolean;'); diff --git a/Units/MMLCore/window.pas b/Units/MMLCore/window.pas index c03e0ab..15119ac 100644 --- a/Units/MMLCore/window.pas +++ b/Units/MMLCore/window.pas @@ -20,6 +20,7 @@ type { TMWindow } TMWindow = class(TObject) + function GetColor(x,y : integer) : TColor; function ReturnData(xs, ys, width, height: Integer): TRetData; procedure FreeReturnData; procedure GetDimensions(var W, H: Integer); @@ -183,6 +184,20 @@ begin inherited; end; +function TMWindow.GetColor(x, y: integer): TColor; +begin + if Self.TargetMode = w_Window then + Result := GetPixel(Self.TargetDC,x,y) + else + begin + with ReturnData(x,y,1,1) do + Result := RGBToColor(Ptr[0].r,Ptr[0].g,Ptr[0].b); + FreeReturnData; + end; + + +end; + function TMWindow.ReturnData(xs, ys, width, height: Integer): TRetData; var {$IFDEF LINUX}