Results 1 to 4 of 4

Thread: ChooseOption

  1. #1
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default ChooseOption

    My ChooseOption function isn't working. It moves the mouse away when it is called. Here's the functions:
    SCAR Code:
    {*******************************************************************************
    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String): Boolean;
    By: Wizzup?, Nava2, and modified by N1ke!
    Description: Finds Popup menu, then clicks on it.
                 Will look for the first string first and so on.
                 It will search for the Text Type you input valid arguments are
                 'action', 'player': The white text
                 'npc': The yellow text
                 'object': The cyan text
                 'all': Searches for all colors of text.
                 Will default to 'all'.
    *******************************************************************************}

    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String): Boolean;
    var
       B, T: TBox;
       TPA, TextTPA: TPointArray;
       aTPA: T2DPointArray;
       I, C, H, HH, ii, L: Integer;
       P: TPoint;
       Occurances: array [0..4] of TPointArray;
       Colors: TIntegerArray;
    begin
      Result := False;
      GetClientDimensions(B.X2, B.Y2);
      B.X1 := 0;
      B.Y1 := 0;
      FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
      If Length(TPA) < 10 Then
        Exit;
      B.X2 := 0;
      B.Y2 := 0;

      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X - 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X1 := P.X;
            B.Y1 := P.Y;
            Break;
          End Else
            C := C + 1;
        End
        Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;
      InvertTPA(TPA);
      C := 0;
      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X + 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X2 := P.X;
            B.Y2 := P.Y;
            Break;
          End Else
            C := C + 1;
        End Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;

      TPA := [];
      Colors := [16777215, 4231423, 2070783, 65535, 16776960];
      case LowerCase(TextType) of
        'action', 'player': FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
        'item'  : begin
                    FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
                    FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
                  end;
        'npc'   : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
        'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
        else
        begin
          FindColorsTolerance(Occurances[0], 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
          FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
          TPA := MergeATPA(Occurances);
          TPA := ReturnPointsNotInTPA(TPA, B);
        end;
      end;
      if High(TPA) < 1 then TPA := MergeATPA(Occurances);
      aTPA := SplitTPAEx(TPA, 7, 1);
      SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

      H := High(Texts);
      L := High(aTPA);
     // for i := 0 to L do
     //   DebugTPA(atpa[i], inttostr(i));

      For I :=0 To H do
      begin
        TextTPA := LoadTextTPA(Texts[i], UpChars, HH);
        for ii := 0 to L do
          If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
          Begin
            T := GetTPABounds(TPA);
            Result := True;
            Mouse(B.X1 + 5, T.y1 - 2, B.X2 - B.X1 - 5, T.Y2 - T.Y1 - 3, True);
            Exit;
          End;
      end;

      MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
      Wait(200 + Random(100));
    end;

    {*******************************************************************************
    function ChooseOptionMulti(Text: TStringArray): Boolean;
    By: Wizzup? modified by N1ke!
    Description: Finds Popup menu, then clicks on it.
    Will look for the first string first and so on.
    *******************************************************************************}

    function ChooseOptionMulti(Txt: TStringArray): Boolean;
    begin
      Result := ChooseOptionMultiEx(Txt, 'All');
    end;

    {*******************************************************************************
    function ChooseOptionEx(Txt, TextType: string): Boolean;
    By: Wizzup?
    Description: Finds an option in a popup menu, then clicks on it. Searches for
                 TextType. See ChooseOptionMultiEx for valid options.
                 Default is 'all'.
    *******************************************************************************}

    function ChooseOptionEx(Txt, TextType: string): Boolean;
    begin
      Result := ChooseOptionMultiEx([Txt], TextType);
    end;

    {*******************************************************************************
    function ChooseOption(txt: String): Boolean;
    By: Wizzup?
    Description: Finds an option in a popup menu, then clicks on it.
    *******************************************************************************}

    function ChooseOption(Txt: String): Boolean;
    begin
      Result := ChooseOptionMultiEx([Txt], 'All');
    end;
    Any fixes?

  2. #2
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    If it moves away the option isn't found.
    Ce ne sont que des gueux


  3. #3
    Join Date
    Mar 2008
    Location
    Look behind you.
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    well, i use the correct text; so i don't know why it misses.

  4. #4
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try using parts of the texts:
    Attack -> ttack
    Talk-to -> alk-to
    And so on..

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
  •