Results 1 to 20 of 20

Thread: [HELP] Getting text from Chatbox

  1. #1
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default [HELP] Getting text from Chatbox

    Hello, I am playing a Private Server but I don't know if it's possible to read text at certain spot.

    http://prntscr.com/b03vj3

    I would like to know this due the fact I than can make something to sip a Prayer Renewal.

    Thank you, sorry if this is the wrong section.

  2. #2
    Join Date
    Jul 2015
    Posts
    80
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    It is with Aerolib, just look at the functions.

  3. #3
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by guer666 View Post
    It is with Aerolib, just look at the functions.
    I looked at it, couldn't find can you post a link and an example perhaps? Thank you.

    Edit : Sorry I forgot to look in the include lol.

  4. #4
    Join Date
    Dec 2007
    Posts
    289
    Mentioned
    4 Post(s)
    Quoted
    86 Post(s)

    Default

    From SRL (using tesseract) (using https://github.com/WarPie/SimpleOCR), derive as you wish:

    Simba Code:
    (*
    Chatbox.GetTextOnLine
    ~~~~~~~~~~~~~~~~~~~~~
    .. code-block:: pascal

      function TRSChatbox.GetTextOnLine(line: Int32; colors:TIntegerArray = CHATBOX_COLORS): String;

    Returns the text at the given line ``[0..8]``. 8 is the last line (the input-field)

    .. note:: by slacky

    Example:
    .. code-block:: pascal

        // returns the text at line 6
        chatbox.GetTextOnLine(6);
    *)

    function TRSChatbox.GetTextOnLine(line: Int32; colors:TIntegerArray = CHATBOX_COLORS): String;
    var
      i,bmp: Int32;
      textArr,temp: TPointArray;
      B: TBox := Self.FLines[line];
    begin
      for i:=0 to High(colors) do
      begin
        FindColorsTolerance(temp, colors[i], B.x1,B.y1,B.x2,B.y2, 0);
        textArr := CombineTPA(textArr, temp);
      end;
      if Length(textArr) = 0 then
        Exit;

      OffsetTPA(textArr, [-B.x1,-B.y1]);
      BMP := CreateBitmap(B.x2-B.x1+1,B.y2-B.y1+2);
      DrawTPABitmap(BMP,textArr,255);

      Result := OCR.RecognizeEx(BitmapToMatrix(bmp),TCompareRules([255]), SmallFont);
      FreeBitmap(bmp);
    end;
    https://github.com/SRL/SRL/blob/mast.../chatbox.simba


    Aerolib:
    Simba Code:
    (*
    GetChatBoxText
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        function getChatBoxText(Line, TextCol: Integer): string;

    Gets text on the line Line with colour TextCol.
    (Line 1 is the top, Line 8 is the bottom line).
    Colours:

        - clMessage/clBlack - Black text messages ("Oh Dear you are dead", etc).
        - clChat/clBlue     - Chat messages from you and other players.
        - clTrade/clPurple  - Colour of trade request text.
        - clFriend          - Colour of friend and clan chat.

    Works with other colours too.


    .. note::

        by ZephyrsFury
        Last modified: 23/1/14 by Flight

    Example:

    .. code-block:: pascal


    *)

    function getChatBoxText(Line, TextCol: Integer): string;
    var
      B    : TBox;
      P    : TPoint;
      bCol : TColEx;
      cArr : TPointArray;
    begin
      Result := '';
      P := getTextCoords(Line);
      bCol.create(TextCol, 0);
      if bCol.findAllIn(toBox(MCX1,P.y,MCX2,P.y+13), cArr) then
      begin
        B := cArr.getBounds();
        result := Trim(getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07));
      end;
    end;
    https://github.com/J-Flight/AeroLib/...ore/Chat.simba

  5. #5
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by honeyhoney View Post
    From SRL (using tesseract), derive as you wish:

    Simba Code:
    (*
    Chatbox.GetTextOnLine
    ~~~~~~~~~~~~~~~~~~~~~
    .. code-block:: pascal

      function TRSChatbox.GetTextOnLine(line: Int32; colors:TIntegerArray = CHATBOX_COLORS): String;

    Returns the text at the given line ``[0..8]``. 8 is the last line (the input-field)

    .. note:: by slacky

    Example:
    .. code-block:: pascal

        // returns the text at line 6
        chatbox.GetTextOnLine(6);
    *)

    function TRSChatbox.GetTextOnLine(line: Int32; colors:TIntegerArray = CHATBOX_COLORS): String;
    var
      i,bmp: Int32;
      textArr,temp: TPointArray;
      B: TBox := Self.FLines[line];
    begin
      for i:=0 to High(colors) do
      begin
        FindColorsTolerance(temp, colors[i], B.x1,B.y1,B.x2,B.y2, 0);
        textArr := CombineTPA(textArr, temp);
      end;
      if Length(textArr) = 0 then
        Exit;

      OffsetTPA(textArr, [-B.x1,-B.y1]);
      BMP := CreateBitmap(B.x2-B.x1+1,B.y2-B.y1+2);
      DrawTPABitmap(BMP,textArr,255);

      Result := OCR.RecognizeEx(BitmapToMatrix(bmp),TCompareRules([255]), SmallFont);
      FreeBitmap(bmp);
    end;
    https://github.com/SRL/SRL/blob/mast.../chatbox.simba


    Aerolib:
    Simba Code:
    (*
    GetChatBoxText
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        function getChatBoxText(Line, TextCol: Integer): string;

    Gets text on the line Line with colour TextCol.
    (Line 1 is the top, Line 8 is the bottom line).
    Colours:

        - clMessage/clBlack - Black text messages ("Oh Dear you are dead", etc).
        - clChat/clBlue     - Chat messages from you and other players.
        - clTrade/clPurple  - Colour of trade request text.
        - clFriend          - Colour of friend and clan chat.

    Works with other colours too.


    .. note::

        by ZephyrsFury
        Last modified: 23/1/14 by Flight

    Example:

    .. code-block:: pascal


    *)

    function getChatBoxText(Line, TextCol: Integer): string;
    var
      B    : TBox;
      P    : TPoint;
      bCol : TColEx;
      cArr : TPointArray;
    begin
      Result := '';
      P := getTextCoords(Line);
      bCol.create(TextCol, 0);
      if bCol.findAllIn(toBox(MCX1,P.y,MCX2,P.y+13), cArr) then
      begin
        B := cArr.getBounds();
        result := Trim(getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07));
      end;
    end;
    https://github.com/J-Flight/AeroLib/...ore/Chat.simba
    I tried to find the text Welcome with AeroLib didn't seem to work

    http://prntscr.com/b07g2e

    The SRL one, don't know how to use it. I hope you can help me out.

  6. #6
    Join Date
    Dec 2007
    Posts
    289
    Mentioned
    4 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by Failure View Post
    I tried to find the text Welcome with AeroLib didn't seem to work

    http://prntscr.com/b07g2e

    The SRL one, don't know how to use it. I hope you can help me out.
    FindChatBoxText uses:
    Simba Code:
    getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07));
    The font set being used is called "SmallChars07", it looks like the font set being used by the chat box on the private server isn't the same (compare to W on Welcome to that of the Welcome on OSRS).


  7. #7
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by honeyhoney View Post
    FindChatBoxText uses:
    Simba Code:
    getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07));
    The font set being used is called "SmallChars07", it looks like the font set being used by the chat box on the private server isn't the same (compare to W on Welcome to that of the Welcome on OSRS).

    It's a different W, the W in your picture you can make a penis if you remember it with the q q p text lol. How do I find the that is used?

    http://prntscr.com/b07u5x

  8. #8
    Join Date
    Dec 2007
    Posts
    289
    Mentioned
    4 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by Failure View Post
    It's a different W, the W in your picture you can make a penis if you remember it with the q q p text lol. How do I find the that is used?

    http://prntscr.com/b07u5x
    Take a look in /Simba/Fonts/ for a list of fonts. I think it might be "SmallChars". All you have to do then is update the function / duplicate it and use SmallChars instead of SmallChars07.

  9. #9
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by honeyhoney View Post
    Take a look in /Simba/Fonts/ for a list of fonts. I think it might be "SmallChars". All you have to do then is update the function / duplicate it and use SmallChars instead of SmallChars07.
    I think so to, but than I'm pretty confused what to use like this

    If (Text('Welcome') then
    WriteLn('Found');

    How would the finding text look like? Really new at this.

    Oh and where do I update the font usage?

  10. #10
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    result := Trim(getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07)) ;
    smallchars07 -> whatever is the correct font.

  11. #11
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    result := Trim(getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07)) ;
    smallchars07 -> whatever is the correct font.
    I'm not sure what you mean, I'm sorry.

  12. #12
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    result := Trim(getTextAtExWrap(b.x1-1,p.y,B.x2+1,p.y+13,0,5,2,TextCol,0,SmallChars07));
    smallchars07 -> whatever is the correct font.
    ...

  13. #13
    Join Date
    Feb 2015
    Location
    Taguig, Philippines
    Posts
    342
    Mentioned
    15 Post(s)
    Quoted
    137 Post(s)

  14. #14
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    ...
    Lol sorry, looked straigth over it.


    Still seems I can't get it to work tried multiple fonts.

    @Renzanity, thanks seems quite useful.

  15. #15
    Join Date
    Jul 2015
    Posts
    80
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Just use getchatboxtext from AL, it is working fine.

  16. #16
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by guer666 View Post
    Just use getchatboxtext from AL, it is working fine.
    Nevermind just don't know what to do with it.

    Just won't get the text properly tried many fonts perhaps the chat box is placed different?

  17. #17
    Join Date
    Feb 2012
    Posts
    40
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    You could use a bitmap to search for the text.

    This could get messy if you're searching for lots of text and calling different 'if' statements dependent on chat text, but should be ok for 1 or 2 bitmaps.

    I'm a noob though so could be completely wrong.

  18. #18
    Join Date
    Nov 2010
    Posts
    305
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Okea View Post
    You could use a bitmap to search for the text.

    This could get messy if you're searching for lots of text and calling different 'if' statements dependent on chat text, but should be ok for 1 or 2 bitmaps.

    I'm a noob though so could be completely wrong.
    Since it's more than one text, it'll get messy I think. I wish this worked for me lol.

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

    Default

    Quote Originally Posted by honeyhoney View Post
    From SRL (using tesseract), derive as you wish:

    Simba Code:
    *snip*
    https://github.com/SRL/SRL/blob/mast.../chatbox.simba
    No, not using tessearct. Just not using Simbas builtin OCR engine.
    Last edited by slacky; 05-10-2016 at 06:29 PM.
    !No priv. messages please

  20. #20
    Join Date
    Dec 2007
    Posts
    289
    Mentioned
    4 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    No, not using tessearct. Just not using Simbas builtin OCR engine.
    Edited

    Was under the impression SimpleOCR was built off tesseract!

    I guess this explains some of my confusion regarding the parameters SimpleOCR is fed? (never could work out the whole shadow thing)

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
  •