Results 1 to 6 of 6

Thread: Help with Textfinding

  1. #1
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help with Textfinding

    I'm writing a script for another game and I want Scar to locate text and click on it.
    I'm trying to use:

    Code:
    function IsTextAtEx(x, y: Integer; S: string; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, 
    MaxSpacing: Integer; TextColor: Integer): Boolean;
    Checks if text specified by S is at location specified by x, y. Tolerance specifies acceptable color range in case characters are not completely
    monochrome, Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2, CheckShadow specifies whether function
    should look for shadow, CheckOutline specifies whether function should verify if character borders are correct, MinSpacing and MaxSpacing
    are RS1 and RS2 specific parameters for text with changing spacing between characters, in other cases use MinSpacing=0 and
    MaxSpacing=0,  TextColor specifies text color, if set to -1, will search for text in any color.
    (found on the Scar help page)
    But I don't quite understand one of the terms.

    What is the so called ''font number returned by LoadCharsFromFont2''
    This is the font I'm *trying* to use.
    SCAR Code:
    LoadCharsFromFont2('Arial', 10, False, False, True, False);

    I'm planning on using:
    SCAR Code:
    if(IsTextAtEx(x, y: Integer; S: string; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing,
    MaxSpacing: Integer; TextColor: Integer))then
    //rest of procedure

    Will that work (I'm pretty sure there needs to b an '=true' in there somewhere), and if not how can I make Scar determine where a string of text is then click on it.

    This is proving very difficult for me, but I figured here was the best place to ask for help.

    Thanks in advance, and if you don't understand what I'm asking then pls ask me to clarify.

    Regards
    ~Gumby

  2. #2
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I believe all LoadChars procedure are meant for the runescape letters library found in Scar/SRL. If you want to find a certain text, you may have to create your own bitmaps of each letter. Anyone correct me if i am wrong, please, since i also do not have too much experience in text :P

  3. #3
    Join Date
    Feb 2006
    Posts
    406
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    LoadCharsFromFont2 should work to load the font

    for IsTextAtEx...
    tolerance=0 if the text is a solid color
    checkshadow=false
    checkoutline=probably true
    minspacing=0
    maxspacing=probably 2-3
    textcolor=value if its constant, else -1

    if you play around with those, and still cant get it to work, try using IsTextInAreaEx to see if you have the right coordinates

    if that doesnt work, use SaveBitmap on a BitmapMaskFromText and see if you loaded the font correctly

  4. #4
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I tried to do this, just messing around using scar to do things on my desktop and I had a terrible time making it recognize different fonts. Good luck! I hope you get it to work, I couldn't, but I believe masquerader if he says it can be done.

  5. #5
    Join Date
    Feb 2006
    Posts
    406
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by tim0suprem0 View Post
    I tried to do this, just messing around using scar to do things on my desktop and I had a terrible time making it recognize different fonts. Good luck! I hope you get it to work, I couldn't, but I believe masquerader if he says it can be done.
    SCAR Code:
    program RunDesktopProgram;//masquerader
    //Drag crosshair to desktop and set up constants to use
    var
      CharsDesktop,x,y,Width,Height,Mask:integer;

    const
      FontName='Tahoma';  //XP default
      FontSize=8;        //XP default
      FontBold=False;     //XP default
      FontItalic=False;   //XP default
      ProgramName='Mozilla Firefox';  //Make sure it fits on one line

    begin
      CharsDesktop:=LoadCharsFromFont2(FontName,Fontsize,FontBold,FontItalic,False,False);
      Mask:=CreateBitmapMaskFromText(ProgramName,CharsDesktop)
      GetClientDimensions(Width,Height);
      if(FindBitmapMaskTolerance(Mask,x,y,0,0,Width,Height,0,10))then
      begin
        WriteLn('Found');
        GetBitmapSize(Mask,Width,Height)
        ClickMouse(x+Width div 2,y-25,True);
        Wait(100)
        ClickMouse(x+Width div 2,y-25,True);
      end;
    end.

  6. #6
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Wow. Cool thanks! I think I was going wrong at the creating a mask for the text and finding that.

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
  •