Log in

View Full Version : FindTextAt - find x, y?



LordJashin
02-17-2012, 04:37 PM
EDIT: Problems Solved, scroll down to my 1st reply to see what I did

I have scoured search looking for this. Tried changing the original function, using other OCR functions, etc. I have two questions that I couldn't find the answer, or I am too much of a nub to figure out. :duh:

I made my own font set, Simba can read the text, put it in the Fonts folder. My code to load it.

GetClientDimensions(w, h);
Font := TFont.Create;
Font.Name := 'TerraChars';
LoadFont('TerraChars', False);

I figured out how to read text, but how do you find out where it is? TPA's I understand most of it except CHAR ex:

FindTextTPAEx(Color,Tol,xs,ys,xe,ye : integer;var x,y : integer; Txt, Chars : string; Action :fnct_ActionOptions ) : Boolean;
If i remember correctly Chars is any of the Runescape type font sets, like SmallChars, BigChars, etc how would I add my font to that. I think I tried adding it to the char array of them that had BigChars, etc in it.

I'm not scripting for RS, I want to read the text then find where its at on the screen, because this 3D game I'm scripting for. The text for NPCs is always the same size, font, color. And I want to click below the NPC's text. Please help.

Brandon
02-17-2012, 05:07 PM
You can't use that for Anything other than RS..

if you want to find text in a game, create the fonts for it.. aka make a bitmap of each character and blackout the background around the text itself..

Next you'll want to do something like:

if FindDeformedBitmap(bmp...) then
str := str + 'bmpcharacter'.

if str = 'whatever word I'm looking for' then
//do whatever here..

LordJashin
02-17-2012, 08:43 PM
Never mind, I could've sworn I tried this before, anyway the following code does what I wanted. ActivateClient;
wait(1800+Random(200));
GetClientDimensions(w, h);
Font := TFont.Create;
Font.Name := 'TerraChars';
LoadFont('TerraChars', false);
// 42751
FindText(cx, cy, 'eep', 'TerraChars', 0, 0, w-1, h-1);
x := cx;
y := cy;
MoveMouse(x, y + 60);
This script loads the font I created and put in C:\Simba\Fonts\TerraChars
then it searches the whole client targeted for 'eep' text. Finally what I wanted, to move the mouse to the place where FindText(); found the text. Aka cx, cy. It moves the mouse right to the middle of the first "e". I wanted this because in this 3D game, the NPC text is always the same size, font, and color. Its always shown above the NPC, so now I can use this to click on the NPC aslong as the text can be read at any camera angle. I think there's a FindTextEx in SRL somewhere too, that has a color parameter.

Yay no using bitmaps! Imagine all the bitmaps I'd have to use if I didn't have this! :eek: