Results 1 to 4 of 4

Thread: function FindColorArea

  1. #1
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default function FindColorArea

    If this was the wrong section to post this in for non members, then sorry for that. Couldn't find the correct place if this is the wrong one, it said enhancements

    Well, this is a very long function, but it is very useful I just tested it for clicking a willow tree, and it worked GREAT! here was the problem I was having before using this function, which inspired me to make this.

    Now, heres a problem I have seen in chicken killers and other things. The script finds the color of the wall or something and its looking for the chicken. It moves the mouse to the wall, and it doesn't find the text up ttack and hicken...etc. But the thing is, it keeps looking for the color from the same point because it checks top left corner or spirals out from same point...etc., making it repeatedly move the mouse onto that color not finding the text, and not looking at a new part of the runescape screen for the chicken. Now this was a problem, but not anymore! (hopefully :P)

    In this function, I have divided up the runescape screen into 9/9 equally, and the script checks your specified box(s), and if it doesn't find the text once it moves the mouse to the color in the first box, it moves it on to the second box, then third...etc. until it finds it (and if you made it look in those other boxes..etc.) This may sound confusing, but heres in short what it does.

    Looks for color in specified boxes going down the list in order (b1 b2..etc)

    If it finds the color, it moves the mouse to it and looks for the text you specified, and if its there, it results true, clicks if told to and exits.
    if the color is not up where it found the color, it goes on to looking in the next box.

    Goes through the list of boxes, and if it doesn't find the color/text in any of them it Exits.. Because most likely the color isn't on the screen.

    Here it is, the ultimate function!

    note: The reason this isn't in my script yet is because I haven't had time today to put it in, and I just started making this function 3 hours ago, and finished now
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    {***************************************************************************************************
    function FindColorArea(Color, b1, b2, b3, b4, b5, b6, b7, b8, b9: Integer; Text: String; Click: Boolean;): Boolean;
    Descriprion: Finds color in specified boxes. there are 9 boxes on the WHOLE runescape screen. each being 1/9 of the screen.
    Searches boxes in order, until it finds the text + color in the box, then exits and stops searching.
    Text is the text you are looking for if we find the color in a box,
    it will move the mouse to the color and then look for the text, and result true if found. if not found,
    it moves on to looking in next box. Also clicks if text is up if told too.

    Boxes names are 1, 2, 3, 4, 5, 6, 7, 8, 9. Heres where they are in order:
    top left, top middle, top right, middle left, middle middle, middle right, bottom left, bottom middle
    bottom right, 0 to not check a box.

    note: 1,2,4,5 would be the ones that check the main screen not counting mini map, inventory and chat box.
    others would check in those too. Just do the math and estimate how to fraction it.

    ***************************************************************************************************}


    function FindColorArea(Color, Tol, b1, b2, b3, b4, b5, b6, b7, b8, b9: Integer; Text: String; Click: Boolean): Boolean;
    var
      JADX1, JADY1, JADX2, JADY2: Integer;

    begin

    case b1 of

       1: if(b1 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b1 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b1 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b1 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b1 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b1 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b1 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b1 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b1 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b1=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b2 of

       1: if(b2 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b2 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b2 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b2 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b2 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b2 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b2 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b2 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b2 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b2=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b3 of

       1: if(b3 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b3 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b3 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b3 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b3 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b3 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b3 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b3 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b3 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b3=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b4 of

       1: if(b4 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b4 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b4 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b4 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b4 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b4 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b4 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b4 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b4 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b4=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b5 of

       1: if(b5 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b5 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b5 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b5 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b5 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b5 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b5 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b5 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b5 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b5=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b6 of

       1: if(b6 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b6 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b6 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b6 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b6 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b6 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b6 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b6 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b6 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b6=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b7 of

       1: if(b7 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b7 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b7 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b7 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b7 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b7 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b7 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b7 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b7 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b7=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b8 of

       1: if(b8 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b8 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b8 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b8 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b8 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b8 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b8 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b8 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b8 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;


    end;

    if(not(b8=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;

    case b9 of

       1: if(b9 = 1)then
          begin
            JADX1:=0;
            JADY1:=0;
            JADX2:=254;
            JADY2:=167;
          end;

       2: if(b9 = 2)then
          begin
            JADX1:=254;
            JADY1:=0;
            JADX2:=508;
            JADY2:=167;
          end;

       3: if(b9 = 3)then
          begin
            JADX1:=508;
            JADY1:=0;
            JADX2:=764;
            JADY2:=167;
          end;

       4: if(b9 = 4)then
          begin
            JADX1:=0;
            JADY1:=167;
            JADX2:=254;
            JADY2:=334;
          end;

       5: if(b9 = 5)then
          begin
            JADX1:=254;
            JADY1:=167;
            JADX2:=508;
            JADY2:=334;
          end;

       6: if(b9 = 6)then
          begin
            JADX1:=508;
            JADY1:=167;
            JADX2:=764;
            JADY2:=334;
          end;

       7: if(b9 = 7)then
          begin
            JADX1:=0;
            JADY1:=334;
            JADX2:=254;
            JADY2:=503;
          end;

       8: if(b9 = 8)then
          begin
            JADX1:=254;
            JADY1:=334;
            JADX2:=508;
            JADY2:=503;
          end;

       9: if(b9 = 9)then
          begin
            JADX1:=508;
            JADY1:=334;
            JADX2:=764;
            JADY2:=503;
          end;
    end;

    if(not(b9=0))then
    begin
      if(FindColorTolerance(x,y, Color, JADX1, JADY1, JADX2, JADY2, Tol))then
      begin
        MMouse(x,y,2,2);
        if(IsUpText(Text))then
        begin
          Result:=True;
          if(Click=true)then
          begin
            Mouse(x,y,2,2,true);
          end;
          Exit;
        end;
      end;
    end;
    if(not(Result))then
    Writeln('Did not find color in any of specified boxes :(');
    end;


    begin
    end.

  2. #2
    Join Date
    Feb 2007
    Posts
    149
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    pretty neat, but why would u want to check mainscreen, inventory, and chat? i only check one at a time usually for different things. i also think it was easier just making my own.

    "Impressive" - Star

  3. #3
    Join Date
    Oct 2006
    Location
    Ireland
    Posts
    855
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice function.. Fucking huge 0.0

  4. #4
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Alex thanks

    And the reason I made this function check the chats and stuff was because when I was making the boxes (which took me 1 and a half hours lol), I had made it the whole screen, chats, mini map and inventory. So I was like..crap But then I figured out 1 was the top left corner of the main playing window, 2 was top right, 4 was bottom left and 5 was bottom right Read the thing about the chickens I talked about and you'll get why and how this function is useful. This will play a big failsafe in places where theres a lot of the same color, but only 1 of them you are looking for. Feel free to put it in your script, it would make your script quite a big longer too lol

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  2. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM
  3. function FindColorArea
    By JAD in forum RS3 Outdated / Broken Scripts
    Replies: 5
    Last Post: 05-05-2007, 12:14 AM

Posting Permissions

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