Results 1 to 15 of 15

Thread: Text detection location

  1. #1
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default Text detection location

    Hi all,

    I am having a play around with text detection for the login screen on OSRS.

    I am looking at a way to detect the words: New User, Existing User, Username, Password, Login and Cancel.

    The method I have used so far is TPAFromTextWrap, which is able to find the text and create a TPA. The issue I am facing with this though, is the fact that the points it is storing is relevant to the text only, not the whole screen.

    Code that I have used:
    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      TPA:TPointArray;
      w, h:integer;

    begin
      InitAL;
      TPAFromTextWrap('Existing User', 'LoginChars', w, h, TPA);
      DebugTPA(TPA, '');
      writeln(TPA);
    end.


    These are the points within the TPA that is being returned:
    Code:
    [{X = 1, Y = 4}, {X = 2, Y = 4}, {X = 3, Y = 4}, {X = 4, Y = 4}, {X = 5, Y = 4}, {X = 6, Y = 4}, {X = 7, Y = 4}, {X = 2, Y = 5}, {X = 3, Y = 5}, {X = 7, Y = 5}, {X = 2, Y = 6}, {X = 3, Y = 6}, {X = 2, Y = 7}, {X = 3, Y = 7}, {X = 2, Y = 8}, {X = 3, Y = 8}, {X = 6, Y = 8}, {X = 2, Y = 9}, {X = 3, Y = 9}, {X = 4, Y = 9}, {X = 5, Y = 9}, {X = 6, Y = 9}, {X = 2, Y = 10}, {X = 3, Y = 10}, {X = 2, Y = 11}, {X = 3, Y = 11}, {X = 2, Y = 12}, {X = 3, Y = 12}, {X = 7, Y = 12}, {X = 0, Y = 13}, {X = 1, Y = 13}, {X = 2, Y = 13}, {X = 3, Y = 13}, {X = 4, Y = 13}, {X = 5, Y = 13}, {X = 6, Y = 13}, {X = 7, Y = 13}, {X = 9, Y = 6}, {X = 10, Y = 6}, {X = 11, Y = 6}, {X = 12, Y = 6}, {X = 15, Y = 6}, {X = 16, Y = 6}, {X = 10, Y = 7}, {X = 11, Y = 7}, {X = 12, Y = 7}, {X = 15, Y = 7}, {X = 11, Y = 8}, {X = 12, Y = 8}, {X = 13, Y = 8}, {X = 14, Y = 8}, {X = 12, Y = 9}, {X = 13, Y = 9}, {X = 12, Y = 10}, {X = 13, Y = 10}, {X = 14, Y = 10}, {X = 11, Y = 11}, {X = 13, Y = 11}, {X = 14, Y = 11}, {X = 15, Y = 11}, {X = 10, Y = 12}, {X = 14, Y = 12}, {X = 15, Y = 12}, {X = 9, Y = 13}, {X = 10, Y = 13}, {X = 13, Y = 13}, {X = 14, Y = 13}, {X = 15, Y = 13}, {X = 16, Y = 13}, {X = 17, Y = 13}, {X = 21, Y = 1}, {X = 20, Y = 2}, {X = 21, Y = 2}, {X = 22, Y = 2}, {X = 21, Y = 3}, {X = 19, Y = 6}, {X = 20, Y = 6}, {X = 21, Y = 6}, {X = 22, Y = 6}, {X = 20, Y = 7}, {X = 21, Y = 7}, {X = 22, Y = 7}, {X = 21, Y = 8}, {X = 22, Y = 8}, {X = 21, Y = 9}, {X = 22, Y = 9}, {X = 21, Y = 10}, {X = 22, Y = 10}, {X = 21, Y = 11}, {X = 22, Y = 11}, {X = 21, Y = 12}, {X = 22, Y = 12}, {X = 19, Y = 13}, {X = 20, Y = 13}, {X = 21, Y = 13}, {X = 22, Y = 13}, {X = 23, Y = 13}, {X = 26, Y = 6}, {X = 27, Y = 6}, {X = 28, Y = 6}, {X = 29, Y = 6}, {X = 25, Y = 7}, {X = 29, Y = 7}, {X = 25, Y = 8}, {X = 26, Y = 8}, {X = 25, Y = 9}, {X = 26, Y = 9}, {X = 27, Y = 9}, {X = 28, Y = 9}, {X = 26, Y = 10}, {X = 27, Y = 10}, {X = 28, Y = 10}, {X = 29, Y = 10}, {X = 28, Y = 11}, {X = 29, Y = 11}, {X = 25, Y = 12}, {X = 28, Y = 12}, {X = 29, Y = 12}, {X = 25, Y = 13}, {X = 26, Y = 13}, {X = 27, Y = 13}, {X = 28, Y = 13}, {X = 32, Y = 4}, {X = 33, Y = 4}, {X = 32, Y = 5}, {X = 33, Y = 5}, {X = 31, Y = 6}, {X = 32, Y = 6}, {X = 33, Y = 6}, {X = 34, Y = 6}, {X = 35, Y = 6}, {X = 32, Y = 7}, {X = 33, Y = 7}, {X = 32, Y = 8}, {X = 33, Y = 8}, {X = 32, Y = 9}, {X = 33, Y = 9}, {X = 32, Y = 10}, {X = 33, Y = 10}, {X = 32, Y = 11}, {X = 33, Y = 11}, {X = 33, Y = 12}, {X = 34, Y = 12}, {X = 33, Y = 13}, {X = 34, Y = 13}, {X = 35, Y = 13}, {X = 36, Y = 13}, {X = 40, Y = 1}, {X = 39, Y = 2}, {X = 40, Y = 2}, {X = 41, Y = 2}, {X = 40, Y = 3}, {X = 38, Y = 6}, {X = 39, Y = 6}, {X = 40, Y = 6}, {X = 41, Y = 6}, {X = 39, Y = 7}, {X = 40, Y = 7}, {X = 41, Y = 7}, {X = 40, Y = 8}, {X = 41, Y = 8}, {X = 40, Y = 9}, {X = 41, Y = 9}, {X = 40, Y = 10}, {X = 41, Y = 10}, {X = 40, Y = 11}, {X = 41, Y = 11}, {X = 40, Y = 12}, {X = 41, Y = 12}, {X = 38, Y = 13}, {X = 39, Y = 13}, {X = 40, Y = 13}, {X = 41, Y = 13}, {X = 42, Y = 13}, {X = 44, Y = 6}, {X = 45, Y = 6}, {X = 46, Y = 6}, {X = 49, Y = 6}, {X = 50, Y = 6}, {X = 51, Y = 6}, {X = 45, Y = 7}, {X = 46, Y = 7}, {X = 47, Y = 7}, {X = 48, Y = 7}, {X = 50, Y = 7}, {X = 51, Y = 7}, {X = 45, Y = 8}, {X = 46, Y = 8}, {X = 50, Y = 8}, {X = 51, Y = 8}, {X = 52, Y = 8}, {X = 45, Y = 9}, {X = 46, Y = 9}, {X = 50, Y = 9}, {X = 51, Y = 9}, {X = 52, Y = 9}, {X = 45, Y = 10}, {X = 46, Y = 10}, {X = 50, Y = 10}, {X = 51, Y = 10}, {X = 52, Y = 10}, {X = 45, Y = 11}, {X = 46, Y = 11}, {X = 50, Y = 11}, {X = 51, Y = 11}, {X = 52, Y = 11}, {X = 45, Y = 12}, {X = 46, Y = 12}, {X = 50, Y = 12}, {X = 51, Y = 12}, {X = 52, Y = 12}, {X = 44, Y = 13}, {X = 45, Y = 13}, {X = 46, Y = 13}, {X = 47, Y = 13}, {X = 51, Y = 13}, {X = 52, Y = 13}, {X = 53, Y = 13}, {X = 57, Y = 6}, {X = 58, Y = 6}, {X = 59, Y = 6}, {X = 60, Y = 6}, {X = 61, Y = 6}, {X = 62, Y = 6}, {X = 56, Y = 7}, {X = 57, Y = 7}, {X = 60, Y = 7}, {X = 61, Y = 7}, {X = 55, Y = 8}, {X = 56, Y = 8}, {X = 61, Y = 8}, {X = 55, Y = 9}, {X = 56, Y = 9}, {X = 61, Y = 9}, {X = 56, Y = 10}, {X = 57, Y = 10}, {X = 60, Y = 10}, {X = 61, Y = 10}, {X = 57, Y = 11}, {X = 58, Y = 11}, {X = 59, Y = 11}, {X = 60, Y = 11}, {X = 56, Y = 12}, {X = 57, Y = 12}, {X = 57, Y = 13}, {X = 58, Y = 13}, {X = 59, Y = 13}, {X = 60, Y = 13}, {X = 61, Y = 13}, {X = 62, Y = 13}, {X = 55, Y = 14}, {X = 56, Y = 14}, {X = 62, Y = 14}, {X = 55, Y = 15}, {X = 56, Y = 15}, {X = 57, Y = 15}, {X = 62, Y = 15}, {X = 56, Y = 16}, {X = 57, Y = 16}, {X = 58, Y = 16}, {X = 59, Y = 16}, {X = 60, Y = 16}, {X = 61, Y = 16}, {X = 69, Y = 4}, {X = 70, Y = 4}, {X = 71, Y = 4}, {X = 75, Y = 4}, {X = 76, Y = 4}, {X = 77, Y = 4}, {X = 70, Y = 5}, {X = 71, Y = 5}, {X = 76, Y = 5}, {X = 77, Y = 5}, {X = 70, Y = 6}, {X = 76, Y = 6}, {X = 70, Y = 7}, {X = 76, Y = 7}, {X = 70, Y = 8}, {X = 76, Y = 8}, {X = 70, Y = 9}, {X = 76, Y = 9}, {X = 70, Y = 10}, {X = 76, Y = 10}, {X = 70, Y = 11}, {X = 71, Y = 11}, {X = 76, Y = 11}, {X = 70, Y = 12}, {X = 71, Y = 12}, {X = 72, Y = 12}, {X = 75, Y = 12}, {X = 76, Y = 12}, {X = 71, Y = 13}, {X = 72, Y = 13}, {X = 73, Y = 13}, {X = 74, Y = 13}, {X = 75, Y = 13}, {X = 80, Y = 6}, {X = 81, Y = 6}, {X = 82, Y = 6}, {X = 83, Y = 6}, {X = 79, Y = 7}, {X = 83, Y = 7}, {X = 79, Y = 8}, {X = 80, Y = 8}, {X = 79, Y = 9}, {X = 80, Y = 9}, {X = 81, Y = 9}, {X = 82, Y = 9}, {X = 80, Y = 10}, {X = 81, Y = 10}, {X = 82, Y = 10}, {X = 83, Y = 10}, {X = 82, Y = 11}, {X = 83, Y = 11}, {X = 79, Y = 12}, {X = 82, Y = 12}, {X = 83, Y = 12}, {X = 79, Y = 13}, {X = 80, Y = 13}, {X = 81, Y = 13}, {X = 82, Y = 13}, {X = 87, Y = 6}, {X = 88, Y = 6}, {X = 89, Y = 6}, {X = 90, Y = 6}, {X = 86, Y = 7}, {X = 90, Y = 7}, {X = 91, Y = 7}, {X = 85, Y = 8}, {X = 86, Y = 8}, {X = 90, Y = 8}, {X = 91, Y = 8}, {X = 85, Y = 9}, {X = 86, Y = 9}, {X = 87, Y = 9}, {X = 88, Y = 9}, {X = 89, Y = 9}, {X = 90, Y = 9}, {X = 91, Y = 9}, {X = 85, Y = 10}, {X = 86, Y = 10}, {X = 85, Y = 11}, {X = 86, Y = 11}, {X = 85, Y = 12}, {X = 86, Y = 12}, {X = 87, Y = 12}, {X = 91, Y = 12}, {X = 87, Y = 13}, {X = 88, Y = 13}, {X = 89, Y = 13}, {X = 90, Y = 13}, {X = 93, Y = 6}, {X = 94, Y = 6}, {X = 95, Y = 6}, {X = 97, Y = 6}, {X = 98, Y = 6}, {X = 94, Y = 7}, {X = 95, Y = 7}, {X = 96, Y = 7}, {X = 97, Y = 7}, {X = 98, Y = 7}, {X = 94, Y = 8}, {X = 95, Y = 8}, {X = 94, Y = 9}, {X = 95, Y = 9}, {X = 94, Y = 10}, {X = 95, Y = 10}, {X = 94, Y = 11}, {X = 95, Y = 11}, {X = 94, Y = 12}, {X = 95, Y = 12}, {X = 93, Y = 13}, {X = 94, Y = 13}, {X = 95, Y = 13}, {X = 96, Y = 13}]
    You will notice that it is considering the first point found as the top left corner of the client.

    What would be a better way to detect text and its real location on the screen?

  2. #2
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    You are not doing any finding, instead just creating a TPA of the given characters.
    Have a look at how we've done it in SRL:
    Simba Code:
    function TSRL.FindText(out Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean; constref; overload;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox, Tolerance)) then
        Exit(False);

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);
    end;
    https://github.com/SRL/SRL/blob/mast...text.simba#L18

    Ofc, this method will fail if the fonts ever change.
    Last edited by slacky; 08-30-2017 at 12:42 AM.
    !No priv. messages please

  3. #3
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    You are not doing any finding, instead just creating a TPA of the given characters.
    Have a look at how we've done it in SRL:
    Simba Code:
    function TSRL.FindText(out Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean; constref; overload;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox, Tolerance)) then
        Exit(False);

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);
    end;
    https://github.com/SRL/SRL/blob/mast...text.simba#L18

    Ofc, this method will fail if the fonts ever change.
    Gave that a go. Couldn't get it to work. What have I done wrong?

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurMatches:TPointArray;

    function CFindText(var Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox.x1, SearchBox.y1, SearchBox.x2, SearchBox.y2, Tolerance)) then
      begin
        writeln('Did not find colors');
        Exit(False);
      end;

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);

    end;

    begin
      InitAL;
      if CFindText(OurMatches, 'Existing', 'LoginChars', 16777215, 1, ToBox(0, 0, 760, 500)) then
        Writeln('Success');
      Writeln(OurMatches);
      DebugTPA(OurMatches, '');
    end.

    Outputs:
    Code:
    [=================================]
    |        < Aero|Library >         |
    |        ----------------         |
    |          Version  : 2           |
    |          Revision : 1           |
    [=================================]
    [AL] Initiating AeroLib...
    [AL] AeroLib auto-update is disabled
    [AL] Loaded 2 MSObjects.
    [AL] Startup complete!
    []
    Successfully executed.

  4. #4
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Gave that a go. Couldn't get it to work. What have I done wrong?

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurMatches:TPointArray;

    function CFindText(var Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox.x1, SearchBox.y1, SearchBox.x2, SearchBox.y2, Tolerance)) then
      begin
        writeln('Did not find colors');
        Exit(False);
      end;

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);

    end;

    begin
      InitAL;
      if CFindText(OurMatches, 'Existing', 'LoginChars', 16777215, 1, ToBox(0, 0, 760, 500)) then
        Writeln('Success');
      Writeln(OurMatches);
      DebugTPA(OurMatches, '');
    end.

    Outputs:
    Code:
    [=================================]
    |        < Aero|Library >         |
    |        ----------------         |
    |          Version  : 2           |
    |          Revision : 1           |
    [=================================]
    [AL] Initiating AeroLib...
    [AL] AeroLib auto-update is disabled
    [AL] Loaded 2 MSObjects.
    [AL] Startup complete!
    []
    Successfully executed.
    You're searching the entire client which I assume isn't ideal.

  5. #5
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    You're searching the entire client which I assume isn't ideal.
    Yeah I am trying to find the text in the client. Don't want to rely on static boxes to find the login screen information, in case of updates etc like the one we had recently.

  6. #6
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Yeah I am trying to find the text in the client. Don't want to rely on static boxes to find the login screen information, in case of updates etc like the one we had recently.
    e: Slacky pointed out you were using the wrong font

    Well then you will have to split and search each cluster for text.

    BUT in my opinion trying to make the login screen dynamic because it was updated (very minor) for the first time since OSRS was released isn't worth it. It's just another thing that complicates things and can break. On top of that you're pretty much trying to predict updates and hope they only move things around in a pretty way where there is a equal chance they can change more which would nullify everything you've done.

    Others may disagree but sometimes a few static boxes is better than trying to create some super duper dynamic searching epic algorithm.
    Last edited by Olly; 08-30-2017 at 02:47 AM.

  7. #7
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Gave that a go. Couldn't get it to work. What have I done wrong?
    Does this look like the right font?


    Go into the Fonts folder and have a look at the fonts, figure out yourself which one is correct (Think of it as learning excercise).
    Last edited by slacky; 08-30-2017 at 02:37 AM.
    !No priv. messages please

  8. #8
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Does this look like the right font?


    Go into the Fonts folder and have a look at the fonts, figure out yourself which one is correct (Think of it as learning excercise).
    So I did it using SMART and this was the result.



    How come TPAFromTextWrap('Existing User', 'LoginChars', w, h, TPA); can successfully find the characters?

    Another test.


    So end result: I need to create the font if I want to achieve this?
    Last edited by Dan the man; 08-30-2017 at 03:07 AM.

  9. #9
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Ok so i created a font called LoginChars07. Have only made a few letters, enough for the word: Login, which I am able to find using the TPAFromTextWrap function. I also used smart to print them and they are a spitting image.

    LoginChars07.zip



    This, however, does not return anything.

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurMatches:TPointArray;

    function CFindText(var Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox.x1, SearchBox.y1, SearchBox.x2, SearchBox.y2, Tolerance)) then
      begin
        writeln('Did not find colors');
        Exit(False);
      end;

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      writeln(TPAText);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);

    end;

    begin
      InitAL;
      if CFindText(OurMatches, 'Existing', 'LoginChars07', 16777215, 1, ToBox(0, 0, 760, 500)) then
        Writeln('Success');
      Writeln(OurMatches);
      DebugTPA(OurMatches, '');
    end.

  10. #10
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Ok so i created a font called LoginChars07. Have only made a few letters, enough for the word: Login, which I am able to find using the TPAFromTextWrap function. I also used smart to print them and they are a spitting image.
    You failed my excercise, you cant have browsed trough the existing folders properly. The font already exists.. It's called UpChars07 / UpChars07_s

    Quote Originally Posted by Dan the man View Post
    So I did it using SMART and this was the result.



    How come TPAFromTextWrap('Existing User', 'LoginChars', w, h, TPA); can successfully find the characters?
    TPAFromTextWrap doesn't search for the text - I have already told you this.. It creates a TPA from the given characters you passed to it, this TPA can then LATER be used to find the Text using FindTextTPAinTPA.
    So to answer your question.. TPAFromTextWrap CAN'T find that text, it doesn't even search for it, it just creates a TPA of the text you passed to it.
    Do you understand this?
    Last edited by slacky; 08-30-2017 at 07:19 AM.
    !No priv. messages please

  11. #11
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    You failed my excercise, you cant have browsed trough the existing folders properly. The font already exists.. It's called UpChars07 / UpChars07_s



    TPAFromTextWrap doesn't search for the text - I have already told you this.. It creates a TPA from the given characters you passed to it, this TPA can then LATER be used to find the Text using FindTextTPAinTPA.
    So to answer your question.. TPAFromTextWrap CAN'T find that text, it doesn't even search for it, it just creates a TPA of the text you passed to it.
    Do you understand this?
    All over it. Attempted to use the code you posted originally with the UpChars07 and UpChars07_s, without any luck.

    DId manage to get Aerolibs: findTextEx seems to work, but findTextTPAEx did not >.<

  12. #12
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Simba Code:
    program new;
    var
      w, h, x, y, bmp: Int32;
      tpa: TPointArray;
    begin
      tpa := TPAFromText('Login', 'UpChars07', w, h);
      bmp := CreateBitmap(w, h);
      DrawTPABitmap(bmp, tpa, $FFFFFF);
      FindBitmap(bmp, x, y);
      WriteLn(x, ' ', y);
      FreeBitmap(bmp);
    end.
    Progress Report:
    272 241

  13. #13
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    All over it. Attempted to use the code you posted originally with the UpChars07 and UpChars07_s, without any luck.

    DId manage to get Aerolibs: findTextEx seems to work, but findTextTPAEx did not >.<
    Ugh, I hate when people trick me to try it myself.
    Simba Code:
    function FindText(var Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox.x1, SearchBox.y1, SearchBox.x2, SearchBox.y2, Tolerance)) then
        Exit(False);

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);
    end;

    var
      Matches:TPointArray;
    begin
      if FindText(Matches, 'Existing', 'UpChars07', 16777215, 1, [0, 0, 760, 500]) then
        Writeln(Matches);
    end.

    And as I expected, it worked just fine:
    > [{X = 418, Y = 285}]

    You really should try harder, I give you clear code and implies that it works, I hint strongly to that the font already exists as well.. Both times you screwed up afaict. Stop doubting me.
    Please run the above code and if it doesn't work for you, then maybe there is in fact a problem. Just run it as is, don't include no extra stuff.
    Last edited by slacky; 08-30-2017 at 09:44 AM.
    !No priv. messages please

  14. #14
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Ugh, I hate when people trick me to try it myself.
    Simba Code:
    function FindText(var Matches: TPointArray; Text, Font: String; Color, Tolerance: Integer; SearchBox: TBox): Boolean;
    var
      TPA, TPAText: TPointArray;
      w, h: Integer;
    begin
      if (not FindColorsTolerance(TPA, Color, SearchBox.x1, SearchBox.y1, SearchBox.x2, SearchBox.y2, Tolerance)) then
        Exit(False);

      SetLength(Matches, 0);
      TPAText := TPAFromText(Text, Font, w, h);
      Result := FindTextTPAinTPA(h - 1, TPAText, TPA, Matches);
    end;

    var
      Matches:TPointArray;
    begin
      if FindText(Matches, 'Existing', 'UpChars07', 16777215, 1, [0, 0, 760, 500]) then
        Writeln(Matches);
    end.

    And as I expected, it worked just fine:
    > [{X = 418, Y = 285}]

    You really should try harder, I give you clear code and implies that it works, I hint strongly to that the font already exists as well.. Both times you screwed up afaict. Stop doubting me.
    Please run the above code and if it doesn't work for you, then maybe there is in fact a problem. Just run it as is, don't include no extra stuff.
    Your a gem <3

    Thanks for your help. I understand it now

  15. #15
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    Simba Code:
    program new;
    var
      w, h, x, y, bmp: Int32;
      tpa: TPointArray;
    begin
      tpa := TPAFromText('Login', 'UpChars07', w, h);
      bmp := CreateBitmap(w, h);
      DrawTPABitmap(bmp, tpa, $FFFFFF);
      FindBitmap(bmp, x, y);
      WriteLn(x, ' ', y);
      FreeBitmap(bmp);
    end.
    Progress Report:
    272 241
    Thanks man. That also works

    Found BitmapFromText which seems to do the same thing.
    Simba Code:
    program new;
    {$DEFINE SMART}
    var
      w, h, x, y, bmp: Int32;
      tpa: TPointArray;
    begin
      bmp := BitmapFromText('Password', 'UpChars07');
      FindBitmap(bmp, x, y);
      WriteLn(x, ' ', y);
      FreeBitmap(bmp);
    end.

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
  •