Results 1 to 13 of 13

Thread: Help FindColorTolerance()

  1. #1
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help FindColorTolerance()

    Hello,

    I am having an issue with a script I wrote. I've written a few basic SCAR scripts in the past so I'm not completely new to the process.

    I am using the ColorPicker to grab the colors for enemy health bars. I save these to a const and then my script uses FindColorTolerance().

    Sample Code:
    SCAR Code:
    var
    x : Integer;
    y : Integer;

    const
    //Color Codes
    enemyHealth1 = 7112404;
    enemyHealth2 = 5136792;
    //Window Scanning
    PxTop = 54;
    PyTop = 144;
    PxBot = 188;
    PyBot = 149;
    //Tolerance
    Tol=100;

    If(FindColorTolerance(x,y,enemyHealth1,PxTop,PyTop,PxBot,PyBot,Tol) OR
       FindColorTolerance(x,y,enemyHealth2,PxTop,PyTop,PxBot,PyBot,Tol))Then
         begin

         end

    However the script is never able to find the colors I specify. I tried adjusting the tolerance and the size of the scan area, but neither worked. I've also checked the colors immediately after running the script and they haven't changed.

    I tried using the following script to get the color codes, but it always returns 0.
    SCAR Code:
    var
    x : Integer;
    x=GetColor(100,145);
    Writeln(IntToStr(x));

    I figure my problem is one of the three:

    • 1) I screwed up the code.
    • 2) I'm running SCAR on Vista x64 and it has an issue reading the screen?
    • 3) The game I'm attempting to automate is preventing me from reading the colors.



    I am able to get SCAR to send key/mouse commands to the game.

    Any input as to what is causing my problem would be great.

    Thanks!

  2. #2
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mhmm. So you are saying that you want to use auto color? Or get the colors? What are you planning to do with this? To see if you're in the fight. If so then infight; helps.

    Also, you could just put
    SCAR Code:
    x,y :integer;
    for you x,y integers.

  3. #3
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    X := GetColor(100,145);
    Writeln(IntToStr(X));

    Would work.

    Can you post your actual script please as
    SCAR Code:
    If(FindColorTolerance(x,y,enemyHealth1,PxTop,PyTop,PxBot,PyBot,Tol) OR
       FindColorTolerance(x,y,enemyHealth2,PxTop,PyTop,PxBot,PyBot,Tol))Then
         begin

         end

    Wont do anything anyways..

    Try this..

    SCAR Code:
    Program New;

    Var
     x: Integer;
     y: Integer;

    Const
     //Color Codes
     enemyHealth1 = 7112404;
     enemyHealth2 = 5136792;
     //Window Scanning
     PxTop = 54;
     PyTop = 144;
     PxBot = 188;
     PyBot = 149;
     //Tolerance
     Tol = 100;

    Procedure Find;
    Begin
      If (FindColorSpiralTolerance(x, y, enemyHealth1, PxTop, PyTop,
       PxBot, PyBot, Tol) Or FindColorSpiralTolerance(x, y, enemyHealth2,
       PxTop, PyTop, PxBot, PyBot, Tol)) Then
    Begin
      Writeln('Found enemy at X: ' + IntToStr(X) + ' Y: ' + IntToStr(Y));
    End;

    End;

    Begin
      Find;
    End.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  4. #4
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Junkj View Post
    Mhmm. So you are saying that you want to use auto color? Or get the colors? What are you planning to do with this? To see if you're in the fight. If so then infight; helps.
    I am checking the enemy health bar to see if my pTarget procedure has picked up an enemy and then again to see when the enemy dies.

    SCAR Code:
    repeat
         while(enemy=False) Do
         begin
             pLook;
             pTarget;
         end;
         while (enemy=True) Do
         begin
             pAttack;
         end;
    until(quit)

    So at the end of the pTarget and pAttack procedure it would use FindColorTolerance() to check whether the enemy healthbar exists.

    I am not familiar with an infight procedure. I should mention that this is not for RS.

  5. #5
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Check my edited post.

    SCAR Code:
    Program New;

    Var
     x: Integer;
     y: Integer;

    Const
     //Color Codes
     enemyHealth1 = 7112404;
     enemyHealth2 = 5136792;
     //Window Scanning
     PxTop = 54;
     PyTop = 144;
     PxBot = 188;
     PyBot = 149;
     //Tolerance
     Tol = 100;

    Procedure Find;
    Begin
      If (FindColorSpiralTolerance(x, y, enemyHealth1, PxTop, PyTop,
       PxBot, PyBot, Tol) Or FindColorSpiralTolerance(x, y, enemyHealth2,
       PxTop, PyTop, PxBot, PyBot, Tol)) Then
    Begin
      Writeln('Found enemy at X: ' + IntToStr(X) + ' Y: ' + IntToStr(Y));
    End;
    End;

    Begin
      Find;
    End.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  6. #6
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here is hacked up version of my full code.

    The problem is that it never find the enemy health bar. I use the Color Picker to check the color and coordinates right before and after I run the script.

    Code:
    program SFrame;
    
    
    var
    enemy : Boolean;
    quit : Boolean;
    x : Integer;
    y : Integer;
    CurrentX : Integer;
    CurrentY : Integer;
    
    const
    //Color Codes
    pethealth1 = 592398;
    pethealth2 = 592142;
    pethealth3 = 5003500;
    pethealth4 = 2368725;
    myhealth1 = 3028290;
    myhealth2 = 3028547;
    myhealth3 = 1645772;
    myhealth4 = 1711565;
    enemyhealth1 = 2040789;
    enemyhealth2 = 2959842;
    enemyhealth3 = 3222759;
    enemyhealth4 = 1974222;
    enemyhealth5 = 5065963;
    enemyhealth6 = 1974219;
    enemyfound = 4752799;
    //Window Scanning
    //Position Codes - Assuming resolution of 1280x1024
    xt = 10;
    yt = 40;
    xb = 1276;
    yb = 996;
    //Health Bar
    HxTop = 166;
    HyTop = 940;
    HxBot = 336;
    HyBot = 947;
    //Mana Bar
    MxTop = 166;
    MyTop = 960;
    MxBot = 336;
    MyBot = 967;
    //Enemy Health
    xtEC = 580;
    ytEC = 50;
    xbEC = 780;
    ybEC = 90;
    //Pet Health
    PxTop = 203;
    PyTop = 913;
    PxBot = 300;
    PyBot = 915;
    //Tolerance
    Tol = 100;
    
    procedure pInitialize;
    begin
         quit := False;
         enemy := False;
         Wait(1000);
    end;
    
    Procedure pLookAround;
    begin
         MoveWindMouseEx(700,380,1,1,10);
         Wait(20+random(10)-random(10));
         GetMousePos(CurrentX,CurrentY);
         HoldMouse(CurrentX,CurrentY,false);
         Wait(100+random(10)-random(10));
         MoveMouse(350+random(10)-random(10),380);
         Wait(200+random(10)-random(10));
         GetMousePos(CurrentX,CurrentY);
         ReleaseMouse(CurrentX,CurrentY,false);
         Wait(800+random(50)-random(50));
    end;
    
    procedure pTarget;
    begin
         Wait(10 + random(10));
         SendKeysVB('=',false);
         Wait(100 + random(50));
         If(FindColorTolerance(x,y,enemyhealth1,PxTop,PyTop,PxBot,PyBot,Tol) OR
         FindColorTolerance(x,y,enemyhealth2,PxTop,PyTop,PxBot,PyBot,Tol))Then
         begin
              enemy:=True;
         end
    end;
    
    procedure pBuff;
    begin
         Wait(10 + random(50));
         KeyDown(17);
         Wait(10 + random(10));
         SendKeysSilent('1');
         Wait(10 + random(10));
         KeyUp(17);
         Wait(1000 + random(50));
         KeyDown(17);
         Wait(10 + random(10));
         SendKeysSilent('2');
         Wait(10 + random(10));
         KeyUp(17);
         Wait(1000 + random(10));
         KeyDown(17);
         Wait(10 + random(10));
         SendKeysSilent('3');
         Wait(10 + random(10));
         KeyUp(17);
         Wait(1000 + random(10));
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('5');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(1000 + random(10));
    end;
    
    procedure pPetHealing;
    begin
              Wait(10 + random(10));
              KeyDown(16);
              Wait(10 + random(10));
              SendKeysSilent('3');
              Wait(10 + random(10));
              KeyUp(16);
              Wait(1100 + random(10));
    end;
    
    procedure pRest;
    begin
         SendKeysWait(',',22000,50);
         SendKeysWait(',',2000,50);
    end;
    
    procedure pAttack;
    begin
    //Set Pet to Attack
         Wait(10 + random(10));
         KeyDown(18);
         Wait(10 + random(10));
         SendKeysSilent('1');
         Wait(10 + random(10));
         KeyUp(18);
         Wait(2000 + random(50));
    //Run and Attack
         SendKeysWait('c',2000,100);
    //Start Casting
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('2');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(2200 + random(50));
         SendKeysWait('1',2000,100);
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('1');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(2000 + random(50));
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('4');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(1600 + random(10));
         SendKeysWait('2',2000,100);
         SendKeysWait('3',3000,100);
         SendKeysWait('4',2000,100);
         SendKeysWait('4',2000,100);
         Wait(3000 + random(50));
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('2');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(2000 + random(50));
         KeyDown(16);
         Wait(10 + random(10));
         SendKeysSilent('1');
         Wait(10 + random(10));
         KeyUp(16);
         Wait(1000 + random(50));
         SendKeysWait('c',2000,100);
         SendKeysWait('2',2000,100);
         If((FindColorTolerance(x,y,enemyhealth1,PxTop,PyTop,PxBot,PyBot,Tol) OR
         FindColorTolerance(x,y,enemyhealth2,PxTop,PyTop,PxBot,PyBot,Tol))=False)Then
         begin
              enemy:=False;
         end
    end;
    
    procedure pLoot;
    begin
         SendKeysWait('-',1000,50);
         ClickWindMouse(321,457,2,2,True);
         Wait(1000);
    end;
    
    
    begin
         pInitialize;
         repeat
              pBuff;
              while(enemy=False) Do
              begin
                 pLookAround;
                 pTarget;
              end;
              while(enemy=True) Do
              begin
                 pAttack;
              end;
              pLoot;
              pPetHealing;
              pRest;
         until(quit)
    end.

  7. #7
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What game is this for? WoW by any chance?

    Can you get a screenshot?.

    Have you tried FindColorSpiralTolerance?

    If you run a simple test of

    SCAR Code:
    X := GetColor(100,200);
    Writeln(IntToStr(X));

    Replace co-ords with where the HP bar is and see what it returns.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  8. #8
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It's not for WoW. It's for a game in China.

    It's my understanding that FindColorSpiralTolerance() functions like FindColorTolerance() except that the search pattern is a spiral?

    SCAR Code:
    X := GetColor(100,200);
    Writeln(IntToStr(X));

    I've done this and it always returns 0. That was my original question. Is it returning 0 because:

    A) I screwed up my code.
    B) I have an issue running SCAR on Vista x64.
    C) The game blocks SCAR's ability to get colors.

  9. #9
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Im running SCAR on Win 7 x64. Doubt game is stopping it.

    Are you targeting the game correctly?.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  10. #10
    Join Date
    Sep 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Im running SCAR on Win 7 x64. Doubt game is stopping it.

    Are you targeting the game correctly?.
    I believe so. I am dragging the Crosshairs to the game window. I get the message 'New client targeted'. I then click on the game and hit Ctrl+Alt+R.

    All of the mouse and key commands go through. It is only the GetColor/FindColor that seems to be failing.

  11. #11
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program New;

    var
    x,y:Integer;

    begin
    If(FindColorSpiralTolerance(x,y,7112404,54,144,188,149,50))Then
    begin
    writeln(x);
    writeln(y);
    end;
    end.

    Try that. Target the game and run.

    Screenshot of game?

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  12. #12
    Join Date
    Jan 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have the same problem on my Windows Vista 32-bit
    GetColor function returns 0 in every point of the selected window.

  13. #13
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by IRON View Post
    I have the same problem on my Windows Vista 32-bit
    GetColor function returns 0 in every point of the selected window.
    Some games somehow block Simba/SCAR. The only solution is to auto/macro on it without selecting the window.

    And by the way, this thread is old, and not active and it's generally frown upon to post in such threads (It's called "to gravedig")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •