From: Laimonas171
oh, I though it was universal example. :D tried to get chat text :X sorry let my check again\
EDIT: TY, rep++
Well I just tried a little Simba scripting which I haven't done in a while. The goal is to write the most efficient font info needed to find specific text around RS.
The below is all I can come up with within the last 15 mins. It's pretty accurate. Seems to get MOST of the fonts, tolerances and spacing correct to find text accurately. It then prints out what values you should enter into GetTextAtExWrap :spongebob:
You can try it and see if it gives good results. It should be able to tell you what fonts and settings to use.
Accuracy is the amount of matches before it considers a result good. Usually I leave it at 1 as it seems to give best results at 1. More than 1 is for more matches. Inother words, if you need it to find 4 instances of the same text, then enter 4. Usually 1 is all you ever need though so I suggest leaving it at that.
{$I SRL/SRL.Simba}
type TTextInfo = record
HSpacing: Integer;
MinVSpace: Integer;
MaxVSpace: Integer;
Tolerance: Integer;
FontType: String;
TextFound: String;
end;
type StringExtract = (Numbers, Letters, AlphaNumeric, Others);
Function CharInRange(C: Char; RangeType: StringExtract): Boolean;
Begin
Case RangeType Of
Numbers : Result := ('0' <= C) And (C <= '9');
Letters : Result := (('A' <= C) And (C <= 'Z')) Or (('a' <= C) And (C <= 'z'));
AlphaNumeric : Result := (('0' <= C) And (C <= '9')) Or ((('A' <= C) And (C <= 'Z')) Or (('a' <= C) And (C <= 'z')));
Others : Result := Not ((('0' <= C) And (C <= '9')) Or ((('A' <= C) And (C <= 'Z')) Or (('a' <= C) And (C <= 'z'))));
End;
End;
Function ExtractFromString(Input: String; RangeType: StringExtract): String;
var
I: Integer;
Begin
For I := Length(Input) DownTo 1 Do
If CharInRange(Input[I], RangeType) Then
Result := Input[I] + Result;
End;
Function MatchPartialTextCount(TextToFind: TStringArray; InputText: TStringArray): Integer;
var
I, J: Integer;
Expression, Haystack: String;
Begin
If (Length(InputText) < 1) Then
Exit;
For I := 0 To High(InputText) Do
For J := 0 To High(TextToFind) Do
Begin
Expression := ExtractFromString(TextToFind[J], AlphaNumeric);
Haystack := ExtractFromString(InputText[I], AlphaNumeric);
If ((Length(TextToFind) > 0) And (Length(InputText[I]) > 0)) Then
If ExecRegExpr(Expression, Haystack) Then
Inc(Result);
End;
End;
Function FindTextInfo(TextToFind: TStringArray; Area: TBox; Colour, MaxTolerance, Accuracy: Integer): TTextInfo;
var
I, J, K: Integer;
Fonts: TStringArray;
Found: String;
Begin
Fonts := ['BigChars', 'CharsNPC', 'CharsTrade', 'FriendChars', 'LoginChars', 'SmallChars', 'SmallCharsNS', 'StatChars', 'UpChars', 'UpCharsEx', 'XPChars'];
For I := 0 To MaxTolerance Do
If (FindColorTolerance(K, J, Colour, Area.X1, Area.Y1, Area.X2, Area.Y2, I)) Then
Begin
K := I + 3;
Break;
End;
For I := 0 To High(Fonts) Do
For J := 0 To 10 Do
For K := 0 To High(TextToFind) Do
Begin
Found := GetTextAtExWrap(Area.X1, Area.Y1, Area.X2, Area.Y2, 0, 0, J, Colour, K, Fonts[I]);
If (MatchPartialTextCount(TextToFind, [Found]) >= Accuracy) Then
Begin
Result.FontType := Fonts[I];
Result.HSpacing := J;
Result.MinVSpace := 0;
Result.MaxVSpace := 0;
Result.Tolerance := K;
Result.TextFound := Found;
Exit;
End;
End;
End;
var
Info1, Info2: TTextInfo;
begin
Info1 := FindTextInfo(['1,024,286,387 gp'], IntToBox(522, 283, 640, 299), 6334462, 5, 1);
writeln(Info1); //Prints 1.xx billion GP Info..
writeln('');
writeln('');
Info2 := FindTextInfo(['Your money pouch'], IntToBox(223, 514, 516, 529), 0, 5, 1);
writeln(Info2); //Prints the Your Moeny Pouch has Info.
end.
For me it printed:
Compiled successfully in 1092 ms.
(3, 0, 0, 2, 'UpCharsEx', '1 , 0 2 4 , 2 8 6 , 3 8 7 g p')
(3, 0, 0, 0, 'SmallChars', 'Y o u r m o n e y p o u c h c u r r e n t l y c o n t a ?r n s 1 6? '' 0? 8 0 c o r n s ')
Successfully executed.