SRL Archive - OSR Help

Get text in Runescape


kazhual

2012-11-21 18:41:29

Hello,

I'm Having trouble reading a text in Runescape This is my script:

program DeclarePlayers;
{$DEFINE SMART}
{$i srl/srl.simba}

var
x,y : integer ;
DTM1, DTM2 : integer ;
ItemBox : array[0..1] of Tpoint ;
textresult : string ;

begin

DTM1 := DTMFromString('mQwAAAHicY2ZgYHBkYmBwYYLQZowQbAnEy5cvZ/j79y8YcwHVwTAjEgYCAFnTCXw=');
DTM2 := DTMFromString('mQwAAAHicY2YAAmYGhr9MENqMEYItgXj58uUMf//+BWMuoDQMMyJhIAAAZvQJtQ==');

if ( FindDTM(DTM1,x,y,525,180,769,506 ) ) then begin
ItemBox[0] := Point( x, y ) ;
end;

if ( FindDTM(DTM2,x,y,525,180,769,506 ) ) then begin
ItemBox[1] := Point( x, y ) ;
end;

textresult := '-1' ;

Writeln( '************' ) ;
Writeln( textresult ) ;
Writeln( '************' ) ;
Writeln( '' ) ;


ItemBox[0].x := ItemBox[0].x + 51 ;
ItemBox[0].y := ItemBox[0].y + 4 ;
ItemBox[1].x := ItemBox[1].x - 8 ;
ItemBox[1].y := ItemBox[1].y + 22 ;

MoveMouse( ItemBox[0].x, ItemBox[0].y );
wait( 1000 ) ;
MoveMouse( ItemBox[1].x, ItemBox[1].y );
wait( 1000 ) ;

FreeDTM( DTM1 ) ;
FreeDTM( DTM2 ) ;

textresult := GetTextAtExWrap(ItemBox[0].x,ItemBox[0].y,ItemBox[1].x,ItemBox[1].y,10,50,2,7067128,20,SmallChars) ;

Writeln( '************' ) ;
Writeln( textresult ) ;
Writeln( '************' ) ;
Writeln( '' ) ;

end.

When I run the Script the "ItemBox" will leave the next part of the minigame picture:
The output will remain:
************
-1
************

************
************

Successfully executed.

Can anyone help me out to get the text string ?
I dont really care what function i need to use as long as it will work :)

kazhual

2012-11-21 18:53:19

The next function doens work for me ?

textresult := GetTextAtEx( ItemBox[0].x, ItemBox[0].y, ItemBox[1].x, ItemBox[1].y, 1, 50, 2, 7067128, 10, SmallChars ) ;

I get the error:
[Error] C:\_Simba_Scripts\Testing.simba(50:122): Invalid number of parameters at line 49

But i am really sure i use all the right parameters.

Silentcore

2012-11-21 18:54:51

Does it open another tab where parameters show?

kazhual

2012-11-21 18:56:28

No it only gives the error, and im really using 11 vars

kazhual

2012-11-21 18:58:44

When i opened the function i find this:

function GetTextAtEx(x, y: Integer; Tolerance: Integer; Chars: String; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer; TextLength: Integer; Strict: Boolean; Range: TCharRange): string; 

A working function would be nice for me:)

riwu

2012-11-21 19:17:47

How do you determine the upper left and btm right points of the box through DTM?
I'd personally use TPA and get the bounds.

Also i think the font is UpCharsEx.

Why not just use WaitOption?

kazhual

2012-11-21 19:25:23

From: riwu
How do you determine the upper left and btm right points of the box through DTM?
I'd personally use TPA and get the bounds.

Also i think the font is UpCharsEx.

Why not just use WaitOption?



Yes i use a dtm to get the position of the new popup screen in your inv.
Its not fully tested.
The menu isnt fixed and moves depeninding on location in inv and the item.

But can you give me a working example of the given picture?
Cant upload the entire screen of rs atm.

riwu

2012-11-21 19:27:52

Where does the 'Amulet of glory (4)' appear at? As a right click option in inventory or equipment?

kazhual

2012-11-21 19:30:08

In the inventory when youre mouse is on the glory without clicking.
Ive tested in paint for this menu so thats why the finddtm is a lil odd

riwu

2012-11-21 19:39:46

writeln(GetUptext);
Move your mouse over the item, and wait a bit before calling it.

kazhual

2012-11-21 19:40:36

Ive been using the get uptext, but sometimes the backround at getuptext screws the result up. So i was trying to use the new function in rs. What would not mess the result up, hopefully.

riwu

2012-11-21 19:43:25

Hmm that's coincidentally what i attempted yesterday too.
Just use fixed coordinates for the search box parameter? Uptext position won't change. I'm lost as to how you are using DTM to find the box, like what are these DTMs?

kazhual

2012-11-21 19:50:11

Dtm1 : upper left popup screen when mouse is on item (grey pixel)
Dtm2 : same as dtm1 but then the upper right.

After the given ofset the name of the item is left ( not 100% tested )

The given coords to look for the dtm are not permanent as i was tesing in paint .
This will change to a more logic something like mix2 and miy2. But i cant in paint :)

riwu

2012-11-21 20:04:24

I'm even more confused now -.-

Can you show a screenshot of where the item is, and where is the text you are grabbing, and where are your DTMs?

Also why do you move your mouse to a point, then wait for 1sec without doing anything, then move to another point (also you should use MMouse for it, much less bot-like)

kazhual

2012-11-22 01:58:42

Yes, Moving the mouse is bot-like.
I use it to see where the DTM starts so i could make the offset for isolating the text of the item.
If the mouse is moved the screen popup is gone.



riwu

2012-11-22 02:37:33

Oh new EOC window…

Get the TPA bound of the words (it should be an unique color), then use that as the search area? Where are your DTM mainpoint and subpoints?

Also vertical spacing should be 0 if you are only getting the 'Amulet of glory' text.

kazhual

2012-11-22 11:07:55

From: riwu
Oh new EOC window…

Get the TPA bound of the words (it should be an unique color), then use that as the search area? Where are your DTM mainpoint and subpoints?

Also vertical spacing should be 0 if you are only getting the 'Amulet of glory' text.


I get the upper left and the upper right points.
With the offset given in the program:


ItemBox[0].x := ItemBox[0].x + 51 ;
ItemBox[0].y := ItemBox[0].y + 4 ;
ItemBox[1].x := ItemBox[1].x - 8 ;
ItemBox[1].y := ItemBox[1].y + 22 ;

Edit:

ItemBox[0] = upper left Popup box
ItemBox[1] = upper right Popup box

Its just in a beta for me. When i can read the text ill improve it :)
But reading failed so i asked help.
Going to set vspacing to 0, both Min and Max and i'll look what will happen.

Edit:


Changed minVspacing & maxVspacing to 0
Changed font to : UpCharsEx
Output: 'A m u l e t o f g l o r y M )'

Changed hspacing to 1 & 0:
Output: 'A m u l e t o f g l o r y ( 4 )'
This function wil do for me :)

kazhual

2012-11-22 11:58:22

Finishing Touch:
Moving mouse to inventory spot 4,

Results i got so far:
- N a t u r e t i a r a
- A m u l e t o f g l o r y ( 4 )
- P r a y e r p o t i o n ( 4 )
- S u p e r s t r e n g t h ( 1 )
- S u p e r a t t a c k ( 2 )

Too bad about the spaces


program FindItemEOC;
{$DEFINE SMART}
{$i srl/srl.simba}

var
x,y : integer ;
Color, Tol : integer;
DTM1, DTM2 : integer ;
ItemBox : array[0..1] of Tpoint ;
textresult : string ;

begin

SRL_SixHourFix := True ;
Smart_FixSpeed := True ;
ClearDebug ;
SetupSRL ;

MMouseItem( 4 );

wait( 1000 );
{
MoveMouse(
MIX1 + 153 ,
MIY1 + 36 )
wait ( 1000 ) ;
}
DTM1 := DTMFromString('mQwAAAHicY2ZgYHBkYmBwYYLQZowQbAnEy5cvZ/j79y8YcwHVwTAjEgYCAFnTCXw=');
DTM2 := DTMFromString('mQwAAAHicY2YAAmYGhr9MENqMEYItgXj58uUMf//+BWMuoDQMMyJhIAAAZvQJtQ==');

ClearDebug ;
textresult := '' ;
Color := 7067128 ;
Tol := 10 ;

if ( FindDTM(DTM1,x,y,MIX1,MIY1,MIX2+27,MIY2 ) ) then begin

ItemBox[0] := Point( x, y )

if ( FindDTM(DTM2,x,y,MIX1,MIY1,MIX2+27,MIY2 ) ) then begin

ItemBox[1] := Point( x, y )
ItemBox[0].x := ItemBox[0].x + 51 ;
ItemBox[0].y := ItemBox[0].y + 4 ;
ItemBox[1].x := ItemBox[1].x - 8 ;
ItemBox[1].y := ItemBox[1].y + 22 ;
textresult := GetTextAtExWrap( ItemBox[0].x, ItemBox[0].y, ItemBox[1].x, ItemBox[1].y, 0, 0, 1, Color, Tol, UpCharsEx) ;

end;

end;

FreeDTM( DTM1 ) ;
FreeDTM( DTM2 ) ;

Writeln( '************' ) ;
Writeln( textresult ) ;
Writeln( '************' ) ;
Writeln( '' ) ;

end.

Posting this in the Devellopment section in case there is some interest