spartakos Posted December 29, 2013 Share Posted December 29, 2013 Hallo guys.I need some help here. I'm trying to make a script that can recognise many colors and when it does to press space. Untill now I made that which works just fine but I don't know how to add more colors: Program FindColorClickColor; Const Color = 7167576; // color you wish to click Procedure FindClick; Var X,Y,W,H: Integer; begin GetClientDimensions(W,H); If FindColorTolerance(X,Y,7167576,81, 170, 1250, 845, 4) then Begin MoveWindMouse(X,Y,81, 170); ClickMouse(X,Y,True); SendKeys(chr(32)); end; end; begin Repeat // Repeats for ever.. or until program is stopped. FindClick; Wait(150); ClickMouseBox(81, 170,1250, 845, True); Until False; end. Then I tried to use the MaxColor but it wasn't effective att all. It doesn't find anythin at all... Program FindColorClickColor; Const MaxColors = 3; Var Colors: Array[0..MaxColors] of Integer; Procedure DeclareColors; begin Colors[0] := 2570874; Colors[1] := 7167576; Colors[2] := 786687; end; Procedure FindClick; Var X,Y,W,H: Integer; begin GetClientDimensions(W,H); If FindColorTolerance(X,Y,MaxColors,81, 170, 1250, 845, 4) then Begin MoveWindMouse(X,Y,81,170); ClickMouse(X,Y,True); SendKeys(chr(32)); end; end; begin Repeat // Repeats for ever.. or until program is stopped. FindClick; Wait(150); ClickMouseBox(81, 170,1250, 845, True); Until False; end. Am I doing something wrong? It seems that the one with Tolerance works better but is it possible to add more colors? Do you have anything else to suggest? Quote Link to comment Share on other sites More sharing options...
Turbine1991 Posted December 29, 2013 Share Posted December 29, 2013 It's no wonder "MaxColors" didn't find anything, it doesn't make any sense at all. MaxColors = 3; ... Colors: Array[0..MaxColors] of Integer; ... If FindColorTolerance(X,Y,MaxColors,81, 170, 1250, 845, 4) then You're looking for a color with a color code of 3!? It's not magic. Quote Link to comment Share on other sites More sharing options...
FHannes Posted December 30, 2013 Share Posted December 30, 2013 Hi, please update to the latest version of SCAR. When you do, use FindColorsTol Quote Link to comment Share on other sites More sharing options...
spartakos Posted December 30, 2013 Author Share Posted December 30, 2013 I thought that there I put the number of the colors I'm looking for, and below I name the colors one by one... It doesn't work that way? - - - Updated - - - Hey man, thank you. I just download it but I cannot figure out how to insert the colors I want. I can't find the manual either. Quote Link to comment Share on other sites More sharing options...
slacky Posted December 30, 2013 Share Posted December 30, 2013 (edited) I thought that there I put the number of the colors I'm looking for, and below I name the colors one by one... It doesn't work that way? - - - Updated - - - Hey man, thank you. I just download it but I cannot figure out how to insert the colors I want. I can't find the manual either. SCAR 3.4: const MaxColors = 3; var Colors: Array[0..MaxColors] of Integer; procedure DeclareColors; begin Colors[0] := 2570874; Colors[1] := 7167576; Colors[2] := 786687; end; var Pt: TPoint; begin if FindColorsTol(Pt.x, Pt.y, Colors, 81,170,1250,845, 4) then begin WriteLn(PointToStr(Pt)); MoveMouse(pt.x,pt.y); end; end. FindColors - SCAR Divi Manual if you need a list of all the points on your screen containing the given colors you can use FindColorsTolEx. const MaxColors = 3; var Colors: Array[0..MaxColors] of Integer; procedure DeclareColors; begin Colors[0] := 2570874; Colors[1] := 7167576; Colors[2] := 786687; end; var TPA: TPointArray; //list of coordinates Pt:TPoint; begin if FindColorsTolEx(TPA, Colors, 81,170,1250,845, 4) then begin WriteLn('Found ' + IntToStr(Length(TPA)) +' points containing given colors!'); Pt := TPA[0]; WriteLn('First found:'+ PointToStr(Pt)); MoveMouse(Pt.x, Pt.y); end; end. Edited December 30, 2013 by slacky Quote Link to comment Share on other sites More sharing options...
spartakos Posted January 3, 2014 Author Share Posted January 3, 2014 Hi Slacky. Happy New Year. Thank you very much for your response. I tried the way you recommended but it seemed to be less effective than the FindColorTol in the 3.22 Version, even I used the same color-codes. So I prefared to repeat the command as many times I need it... Do you know any way to exclude some points that have similar colors? Thats my main problem right now.. It keeps clicking in spots I don't want... Those spots are not stable in the screen. Quote Link to comment Share on other sites More sharing options...