Results 1 to 19 of 19

Thread: ChooseTabbedOptionMulti

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default ChooseTabbedOptionMulti

    [Updated 9-30-12]

    function ChooseTabbedOptionMulti(OptionsA, OptionsB: TStringArray): Boolean;

    Parameters
    • OptionsA: First set of options to look for in the Options Menu.
    • OptionsB: Second (and final) set of options to search for & choose.


    Usage
    This is used in the instance the right-click option you're trying to choose isn't visible, rather it's in one of the sub-menus (tab menu). For example, if you're trying to open a bank chest using the option 'Use' but it wasn't visible, you could use this instead: "ChooseTabbedOptionMulti(['Bank','Chest'], ['Use']);". Initially it will check if any of OptionsB are already visible and if so, click them. If not, the function will search for & move to any visible options of OptionsA and then choose the visible OptionsB (if found).

    First, throw this procedure in mouse.simba, anywhere under the WindMouse procedure:
    Simba Code:
    {*******************************************************************************
    procedure AccurateMMouse(eX, eY, ranX, ranY: Integer);
    By: Flight
    Description: Same as MMouse but uses a much straighter path; required
                 for choosing tabbed options.
    *******************************************************************************}

    Procedure AccurateMMouse(eX, eY, ranX, ranY: Integer);
    var
      randSpeed: extended;
      X,Y,MS: integer;
    begin
      MS := MouseSpeed;
      randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
      GetMousePos(X, Y);
      WindMouse(X, Y, RandomRange(eX-ranX, eX+ranX), RandomRange(eY-ranY,eY+ranY), 14, 3, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed, 10.0*randSpeed);
      MouseSpeed := MS;
    end;

    This is required choosing a tabbed option.

    Now go into text.simba and under the "GetChooseOptions" function add this:
    Simba Code:
    {*******************************************************************************
    Function GetTabbedOptions(BigBox: TBox; TextType: string): Array of TOptions;
    By: Flight
    Description: Grabs all the options of the right-click tab menu, if visible.
    *******************************************************************************}

    Function GetTabbedOptions(BigBox: TBox; TextType: string): Array of TOptions;
    var
       B, BB, sB, TabBox: TBox;
       FilteredTPA, TPA, TPA1, TPA2: TPointArray;
       ATPA, tempatpa: T2DPointArray;
       I, L, target, bmp,w,h, cts: Integer;
       BoxColors: TIntegerArray;
    begin
      target := GetImageTarget;
      GetClientDimensions(B.X2, B.Y2);
      B := IntToBox(0, 0, B.X2-1, B.Y2-1);

      //Start tab box
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);

      BoxColors := [131843, 3682593, 3552822];
      SetLength(ATPA, Length(BoxColors));
      for i := 0 to High(BoxColors) do
        FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);

      TPA := MergeATPA(ATPA);
      //Remove the initial bigbox
      ClearTPAFromTPAWrap(TPA,TPAFromBox(BigBox),FilteredTPA);
      If Length(FilteredTPA) < 100 Then
      begin
        ColorToleranceSpeed(cts);
        Exit;
      end;

      ATPA := SplitTPA(FilteredTPA, 4);
      For i := 0 to High(ATPA) do
      begin
        B := GetTPABounds(ATPA[i]);
        if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then
          Break
        else
          B := IntToBox(0, 0, 0, 0);
      end;

      If (B.x2 = 0) then
      begin
        ColorToleranceSpeed(cts);
        Exit;
      end;

      TabBox := B;

      SetColorToleranceSpeed(3);
      FindColorsTolerance(TPA1, 4996381, B.X1, B.Y1, B.X2, B.Y2, 18);
      sB := GetTPABounds(TPA1);
      ReturnPointsNotInTPAWrap(TPA1, sB, TPA);
      FindColorsTolerance(TPA2, 460291, B.X1, B.Y1, B.X2, B.Y2, 6);
      SetColorToleranceSpeed(cts);

      bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
      OffsetTPA(TPA, Point(-B.X1, -B.Y1));
      OffsetTPA(TPA2, Point(-B.X1, -B.Y1));
      FastDrawClear(bmp, 0);
      DrawTPABitmap(bmp, TPA, clRed);
      DrawTPABitmap(bmp, TPA2, clPurple);
      ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
      GetbitmapSize(bmp,w,h);
      SetTargetBitmap(bmp);
      SetLength(ATPA, H div 16);
      for i := 0 to High(ATPA) do
        FindColorsTolerance(ATPA[i], clRed, 0, 2+i*16,  W-1, 18+i*16, 0);
      L := High(ATPA);
      SortATPAFromFirstPointY(ATPA, Point(w div 2,0));

      SetArrayLength(Result, Length(ATPA));
      Result[0].BigBox := TabBox;
      for i := 0 to high(ATPA) do
      begin
        TPA := ATPA[i];
        tempatpa := SplitTPAEx(TPA, 1, 10);
        SortATPAFromFirstPointX(tempatpa, Point(0, 0));
        Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx');
        BB := GetTPABounds(ATPA[i]);
        Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
        setlength(tempatpa,0);
        setlength(TPA,0);
      end;
      ColorToleranceSpeed(cts);
      SetImageTarget(target);
      FreeBitmap(bmp);
    end;

    And finally underneath the "OptionsExist" function add this bit:
    Simba Code:
    function ChooseTabbedOptionMulti(OptionsA, OptionsB: TStringArray): Boolean;
    var
      T: TPoint;
      B,BigBox,TabBox: TBox;
      i, H, ii, L, x: Integer;
      Options,TOptions: array of TOptions;
    begin
      Result := False;
      Options := GetChooseOptions('All');
      if (Length(Options) < 1) then
        Exit;
      BigBox := Options[0].BigBox;

      //Initially check TextsB
      if OptionsExist(OptionsB, False) then
      begin
        Result := ChooseOptionMulti(OptionsB);
        Exit;
      end;

      //Mouse first set of text options
      H := High(Options);
      L := High(OptionsA);
      for i := 0 To L do
      begin
        for ii := 0 to H do
          If Pos(OptionsA[i], Options[ii].Str) > 0 Then
          begin
            Result := True;
            B := Options[ii].Bounds;
            GetMousePos(T.x, T.y);
            if (not PointInBox(T, B)) then
              MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5, mouse_move);
          end;
      end;

      //Secondary options
      TOptions := GetTabbedOptions(BigBox,'All');
      if (Length(TOptions) < 1) then
        Exit;
      L := High(OptionsB);
      H := High(TOptions);
      for i := 0 To L do
      begin
        for ii := 0 to H do
          If Pos(OptionsB[i], TOptions[ii].Str) > 0 Then
          begin
            Result := True;
            TabBox := TOptions[0].BigBox;
            GetMousePos(T.x, T.y);
            AccurateMMouse(RandomRange(TabBox.X1, TabBox.X2), T.Y, 0, 3);
            Wait(200 + Random(100));
            B := TOptions[ii].Bounds;
            GetMousePos(T.x, T.y);
            if PointInBox(T, B) then
              ClickMouse2(Mouse_left)
            else
              MouseBoxEx(B.x1 + 5, B.Y1, B.x2 - 5, B.Y1 + 5,5,mouse_left);
            Exit;
          end;
      end;
      B := TOptions[0].BigBox;
      x := Max(B.X1 - 52, 0);
      if x = 0 then
        x := B.X2+10;
      MMouse(x, Max(B.Y1 - 50, 0), 40, B.Y2-B.Y1);
      Wait(200 + Random(100));
    end;

    If you added everything in the correct locations it should compile right up. I'll also attach mouse.simba & text.simba for you lazy ones.


    ~


    P.S. This is indeed compatible with Lape.
    Last edited by Flight; 09-30-2012 at 08:38 AM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I can't seem to get this to work. I think it's because of the way ChooseOptionMultiEx works. It finds the background color from the mouse position, so the "sub-menu" location wouldn't be detected properly.

    Simba Code:
    (*
    ChooseOptionTabbed
    ~~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        function ChooseOptionTabbed(Txt1, Txt2: TStringArray): Boolean;

    By passes the "sub-menus" that appear in option menus in a crowded area. 'Txt1'
    are the hover options, and Txt2 are the final options.  If Txt2 alread exists
    without hovering, it will click it.  This function should eventually replace
    ChooseOption.

    .. note::

      by Flight
      Last Updated: April 13th, 2012 by Coh3n

    Example:

    .. code-block:: pascal

      Mouse(bank.x, bank.y, 5, 5, mouse_Right);
      Result := ChooseOptionTabbed(['Banker'], ['Bank']);
    *)

    function ChooseOptionTabbed(Txt1, Txt2: TStringArray): Boolean;
    begin
      Result := False;

      if (OptionsExist(Txt2, False)) then
        Result := WaitOptionMultiEx(Txt2, 'All', ClickLeft, 300)
      else
        if (ChooseOptionMultiEx(Txt1, 'All', Move)) then
          Result := WaitOptionMultiEx(Txt2, 'All', ClickLeft, 300);
    end;

  3. #3
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    I can't seem to get this to work. I think it's because of the way ChooseOptionMultiEx works. It finds the background color from the mouse position, so the "sub-menu" location wouldn't be detected properly.
    So then the version you posted did work for you? It's been so long since I posted this.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    No, it doesn't work. And I know it's been a while, I was just looking at unresolved suggestions and I think something like this needs to be added.

  5. #5
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    It's not easy to produce a tabbed menu right when I need it for testing but if you give me some time today I can try and work on this.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I was having trouble with that as well. Take as much time as you need.

  7. #7
    Join Date
    Dec 2009
    Location
    R_GetPlayerLoc;
    Posts
    2,235
    Mentioned
    0 Post(s)
    Quoted
    14 Post(s)

    Default

    I used to get a lot of tabbed menus at w1 lumby bank... just make sure you angle your camera in a way where alot of people get chosen...
    "Logic never changes, just the syntax" - Kyle Undefined?

    Remember, The Edit Button Is There For A Reason!!!

  8. #8
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Well Coh3n I finally have this working correctly, but it requires a couple other functions to work. I gotta say, it took me a bit of time this morning just to make this. :/

    I have it working smooth in AeroLib; implanting this into SRL will require, like I said, extra functions. I guess it depends on if you want this in the include or not. Let me know what you think.


    ~

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  9. #9
    Join Date
    Apr 2012
    Posts
    3,356
    Mentioned
    34 Post(s)
    Quoted
    218 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Well Coh3n I finally have this working correctly, but it requires a couple other functions to work. I gotta say, it took me a bit of time this morning just to make this. :/

    I have it working smooth in AeroLib; implanting this into SRL will require, like I said, extra functions. I guess it depends on if you want this in the include or not. Let me know what you think.


    ~
    Nice work. This looks very slick.. How long exactly did it take to do that?

    (sorry for newbie questions)
    what method of locating did you use, uptext?

  10. #10
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I believe under two hours of hit-and-miss. I had to go through multiple attempts to find one that worked accurately.

    It basically works the same way as our current method of grabbing right-click options (TOptions).

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  11. #11
    Join Date
    Apr 2012
    Posts
    3,356
    Mentioned
    34 Post(s)
    Quoted
    218 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I believe under two hours of hit-and-miss. I had to go through multiple attempts to find one that worked accurately.

    It basically works the same way as our current method of grabbing right-click options (TOptions).
    Oh okay brilliant!
    Wow that's impressive, I still struggle with the basics.
    Ok so would we implement this as an additional method of making us look more human or not?
    I mean after watching the videos it looked so nifty

  12. #12
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    This is great for the large stacks of people! Is there a way to detect if the second option box is needed and just choose the normal chooseoption if it's not needed (ie can detect if no tabs present)?

  13. #13
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    This is great for the large stacks of people! Is there a way to detect if the second option box is needed and just choose the normal chooseoption if it's not needed (ie can detect if no tabs present)?
    Yes, here's the parameters:
    Simba Code:
    function AL_ChooseTabbedOptionMulti(TextA, TextB: TStringArray): Boolean;

    TextA is your (first) array of text that you search for incase TextB isn't visible in the initial Options Menu, and obvious TextB is what you will ultimately be choosing. If any of TextB is already visible in the Options Menu then it will be chosen first and return result True.

    @-Benny:
    I can make this for SRL if Coh3n (or others) would like me to. IMO we should have already had it as a basic core function as it's not just another add-on or antiban, this is really required in some instances.

    It will obviously be included in AeroLib whenever I finish(...) it.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  14. #14
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Yes, here's the parameters:
    Simba Code:
    function AL_ChooseTabbedOptionMulti(TextA, TextB: TStringArray): Boolean;

    TextA is your (first) array of text that you search for incase TextB isn't visible in the initial Options Menu, and obvious TextB is what you will ultimately be choosing. If any of TextB is already visible in the Options Menu then it will be chosen first and return result True.

    @-Benny:
    I can make this for SRL if Coh3n (or others) would like me to. IMO we should have already had it as a basic core function as it's not just another add-on or antiban, this is really required in some instances.

    It will obviously be included in AeroLib whenever I finish(...) it.
    That's awesome and I totally agree it should be in the include

  15. #15
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Indeed nice work Flight. If you can get this working in SRL, then by all means please do. This would be some nice new functionality for srl6.

  16. #16
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    There ya go.

    Edit:
    Could a moderator also change this thread title to "ChooseTabbedOptionMulti"? Please & thank you.
    Last edited by Flight; 09-30-2012 at 08:45 AM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  17. #17
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Honestly, this should just be the standard ChooseOption for SRL-6. Nice work, Flight.

  18. #18
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Beautiful work as always Flight.



    Question for Coh3n:
    Whens that SRL-6 come out, maybe a behind the scenes?

  19. #19
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Question for Coh3n:
    Whens that SRL-6 come out, maybe a behind the scenes?
    It's too early to know an actual release date, but I wouldn't expect it to be soon.

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
  •