SRL Archive - Instructions & Tutorials S.M.A.R.T.

Setting up Embedded SMART


BenLand100

2007-08-20 21:35:02

Firstly copy the dll (in the Release folder) into you're plugin folder. You will also need Java 1.6+ in order to use SMART. Every script that wishes to use a SMART function must call SmartSetup before using any, unless you want to meet Crashzilla. Note that the server string is the server prefix, not world number. Call SmartSetup as follows:

procedure SmartSetup(server: String; hidetail, signed: Boolean);
This will load the server only if its not already loaded, as it takes some time (a few seconds) to init a server. You can call SmartReady (which takes no arguments and returns a boolean) at any time to check if SMART is able to receive commands. The next step is to set Scar's target to SMART. This can be done in 3.06+ by calling SetTargetDC(SmartGetDC); or in 1.13+ by calling the following procedure.
procedure SmartSetTarget;
var
Smart_Bitmap: Integer;
begin
Smart_Bitmap:= BitmapFromString(765,503,'');
GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetDC;
SetTargetBitmap(Smart_Bitmap);
FreeBitmap(Smart_Bitmap);
end;
The next logical step is to redirect mouse and key events. I've made this VERY SIMPLE for all of you poptards out there ;) Simply put the following code in an include and make it the *FIRST* include in you're program (or the program you are converting).

procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;

procedure HoldMouse(x, y: Integer; left: Boolean);
begin
SmartHoldMouse(x, y, left);
end;

procedure ReleaseMouse(x, y: Integer; left: Boolean);
begin
SmartReleaseMouse(x, y, left);
end;

procedure KeyUp(key: Byte);
begin
SmartReleaseKey(key);
end;

procedure KeyDown(key: Byte);
begin
SmartHoldKey(key);
end;

procedure SendKeys(S: String);
begin
SmartSendKeys(S);
end;

procedure GetMousePos(var x, y: Integer);
begin
SmartGetMousePos(x, y);
end;
That will override the specified commands that I've found are most common in SRL and the scripts that I've looked at. Now, since its embedded, you can just override the low level movemouse procedure and use windmouse or anything else from SRL. Note that this does not override any other 'built in' procedures, such as SendKeysSilent or KeyUpSilent, etc. You'll have to do those on a need-to-be-done basis.

SMART also provides other mouse methods for the advanced user.:
procedure SmartWindMouse(x, y: Integer); //Built in WindMouse algorithm
procedure SmartDragMouse(x, y: Integer); //Drags from the current pos to the end pos
procedure SmartClickMouse(x, y: Integer; left: Boolean); //Moves via WindMouse to the pos and clicks
If you are really savvy and want to use some blisteringly fast color searches, you might try SMART's color searching methods. Please note that they do not (as of yet ;)) support scar bitmaps, you must pass the dc of the bitmap which is retrieved via GetBitmapCanvas(bmp).Handle;

function SmartGetColor(x, y: integer): integer;
function SmartFindColor(var x, y: integer; color, sx, sy, ex, ey: integer): boolean;
function SmartFindColorTolerance(var x, y: integer; color, sx, sy, ex, ey, tol: integer): boolean;
function SmartFindColorSpiral(var x, y: integer; color, sx, sy, ex, ey: integer): boolean;
function SmartFindColorSpiralTolerance(var x, y: integer; color, sx, sy, ex, ey, tol: integer): boolean;
function SmartFindBitmap(hdc: integer; var x, y: integer): boolean;
function SmartFindBitmapIn(hdc: integer; var x, y: integer; sx, sy, ex, ey: integer): boolean;
function SmartFindBitmapToleranceIn(hdc: integer; var x, y: integer; sx, sy, ex, ey, tol: integer): boolean;
There is coded support for setting SMART's target (ie. to another image), the different color tolerance modifiers, fast RGB<>HSL conversion, a faster similar colors, and a few other interesting things, but I haven't made them available to Scar yet.

Sumilion

2007-08-21 05:09:05

Sweet stuff :)

Though with this :

begin
SmartSetup('62', False, True);
SetTargetDC(SmartGetDC);
SetupScript;

i get this error :

Could not initialize SMART
Error Code: [16711422]

anything i forgot ?

And the smart client is called Embeded SMART.

Smartzkid

2007-08-21 11:13:48

Okay, I have a few of questions:

-SmartMoveMouse instantly moves the mouse, just like SCAR's?
-In SmartSetup, server is the world prefix, or the world number?

Is there something wrong with this, or do I just have a suicidal SCAR (scar window disappears; process is still running, though)?
program New;
begin
SmartSetup('1', true, false);
repeat
wait(100);
until(SmartReady);
SetTargetDc(SmartGetDC);
DisplayDebugImgWindow(500, 500);
CopyCanvas(GetClientCanvas, GetDebugCanvas, 0, 0, 500, 500, 0, 0, 500, 500);
end.

nielsie95

2007-08-21 11:29:32

I'm having the same problem as Smartzkid, if I run that piece of code scar disappears, but the process keeps on running.

and if I run this once:


program New;
begin
SmartSetup('81', False, True);
SetTargetDC(SmartGetDC);
end.

it gives me

Successfully compiled
Successfully executed

But when I run it again.. Scar disappears again.


EDIT: Got it now, thanks Smartz :)


program New;

begin
SmartSetup('po5', False, True);
repeat
wait(100);
until(SmartReady);
SetTargetDC(SmartGetDC);
DisplayDebugImgWindow(500, 500);
CopyCanvas(GetClientCanvas, GetDebugCanvas, 0, 0, 500, 500, 0, 0, 500, 500);
SmartMoveMouse(100, 100);
end.

Sumilion

2007-08-21 11:56:19

Yeh erm… my error still stands.

BenLand100

2007-08-21 15:49:18

From: Sumilion
Sweet stuff :)

Though with this :

begin
SmartSetup('62', False, True);
SetTargetDC(SmartGetDC);
SetupScript;
i get this error :

Could not initialize SMART
Error Code: [16711422]

anything i forgot ?

And the smart client is called Embeded SMART.

I guess I forgot to mention that it needs Java 1.6+ The regular JDK/JRE will work. That specific error means it can't find the jvm.dll file which it locates via the registry (as java.exe does) Also, I had noticed the name, but i had already compressed and uploaded the file so i didn't bother… If anyone knows a free svn server… :p

program New;
begin
SmartSetup('1', true, false);
repeat
wait(100);
until(SmartReady);
SetTargetDc(SmartGetDC);
DisplayDebugImgWindow(500, 500);
CopyCanvas(GetClientCanvas, GetDebugCanvas, 0, 0, 500, 500, 0, 0, 500, 500);
end.
Yea, it needs the server prefix, not the world number. I'll see about making it give an error instead of crashing however.


EDIT: SmartMoveMouse dose move exactly like MoveMouse. If you want it to move smoothly call SmartWindMouse, however by changing MoveMouse you make the SRL MMouse work for easier compatibility.

Sumilion

2007-08-21 18:43:21

I installed jdk1.6.0_02 but it still gives me the same error message ?

Smartzkid

2007-08-21 19:08:59

Get the latest JRE

Sumilion

2007-08-21 19:12:45

Didnt help, it was because of my Vista ? Anyway, adding a key to the registry seemed to help, thanks to BenLand100 :)

Ejjman

2007-08-21 23:27:04

Wtf is a world prefix TBH? lol.

BenLand100

2007-08-22 02:00:34

From: Ejjman1
Wtf is a world prefix TBH? lol.

at1.runescape.com
at1 is the prefix :p

nielsie95

2007-08-22 05:39:40

I got this from SCSS:


{List generated by Freddy1990's Advanced World Generator}
{http://freddy1990.com/fawg.php}

[Worlds]
Count=144

[World1]
Prefix=ul7
Type=Free

[World2]
Prefix=ul8
Type=Members

[World3]
Prefix=sl1
Type=Free

[World4]
Prefix=po4
Type=Free

[World5]
Prefix=po5
Type=Free

[World6]
Prefix=sl10
Type=Members

[World7]
Prefix=above2
Type=Free

[World8]
Prefix=above3
Type=Free

[World9]
Prefix=above4
Type=Members

[World10]
Prefix=jolt7
Type=Free

[World11]
Prefix=jolt8
Type=Free

[World12]
Prefix=jolt9
Type=Members

[World13]
Prefix=nl3
Type=Free

[World14]
Prefix=nl4
Type=Free

[World15]
Prefix=mn2
Type=Free

[World16]
Prefix=mn3
Type=Free

[World17]
Prefix=nav1
Type=Free

[World18]
Prefix=nav2
Type=Members

[World19]
Prefix=nl7
Type=Free

[World20]
Prefix=nl8
Type=Free

[World21]
Prefix=nl11
Type=Free

[World22]
Prefix=nl1
Type=Members

[World23]
Prefix=mn4
Type=Members

[World24]
Prefix=mn5
Type=Members

[World25]
Prefix=nl12
Type=Free

[World26]
Prefix=ul5
Type=Members

[World27]
Prefix=nl5
Type=Members

[World28]
Prefix=nl6
Type=Members

[World29]
Prefix=ul6
Type=Free

[World30]
Prefix=po7
Type=Free

[World31]
Prefix=po8
Type=Members

[World32]
Prefix=ul1
Type=Free

[World33]
Prefix=at1
Type=Free

[World34]
Prefix=at2
Type=Free

[World35]
Prefix=at3
Type=Free

[World36]
Prefix=at4
Type=Members

[World37]
Prefix=nav3
Type=Free

[World38]
Prefix=ny9
Type=Free

[World39]
Prefix=ny10
Type=Members

[World40]
Prefix=ny11
Type=Free

[World41]
Prefix=ny12
Type=Free

[World42]
Prefix=po2
Type=Members

[World43]
Prefix=sl11
Type=Free

[World44]
Prefix=at6
Type=Members

[World45]
Prefix=ny13
Type=Members

[World46]
Prefix=ny14
Type=Members

[World47]
Prefix=above5
Type=Free

[World48]
Prefix=above6
Type=Members

[World50]
Prefix=ams2
Type=Free

[World51]
Prefix=ams3
Type=Free

[World52]
Prefix=ams4
Type=Free

[World53]
Prefix=ams7
Type=Members

[World54]
Prefix=ams8
Type=Members

[World55]
Prefix=ch1
Type=Free

[World56]
Prefix=nl10
Type=Members

[World57]
Prefix=ch3
Type=Free

[World58]
Prefix=ch4
Type=Members

[World59]
Prefix=ch5
Type=Members

[World60]
Prefix=ch6
Type=Members

[World61]
Prefix=se1
Type=Free

[World62]
Prefix=se2
Type=Free

[World63]
Prefix=se3
Type=Free

[World64]
Prefix=se4
Type=Members

[World65]
Prefix=se5
Type=Members

[World66]
Prefix=se6
Type=Members

[World67]
Prefix=jolt10
Type=Free

[World68]
Prefix=jolt11
Type=Free

[World69]
Prefix=jolt12
Type=Members

[World70]
Prefix=po6
Type=Members

[World71]
Prefix=mn7
Type=Members

[World72]
Prefix=nav9
Type=Free

[World73]
Prefix=sl2
Type=Free

[World74]
Prefix=sl3
Type=Free

[World75]
Prefix=sl4
Type=Free

[World76]
Prefix=sl5
Type=Members

[World77]
Prefix=sl6
Type=Members

[World78]
Prefix=sl7
Type=Members

[World79]
Prefix=sl8
Type=Members

[World80]
Prefix=jolt1
Type=Free

[World81]
Prefix=jolt2
Type=Free

[World82]
Prefix=jolt3
Type=Members

[World83]
Prefix=jolt4
Type=Members

[World84]
Prefix=jolt5
Type=Members

[World85]
Prefix=ny1
Type=Free

[World86]
Prefix=ny2
Type=Free

[World87]
Prefix=ny4
Type=Free

[World88]
Prefix=ny5
Type=Members

[World89]
Prefix=ny6
Type=Members

[World90]
Prefix=ny7
Type=Free

[World91]
Prefix=ny8
Type=Members

[World92]
Prefix=nl9
Type=Members

[World93]
Prefix=mi1
Type=Free

[World94]
Prefix=mi2
Type=Free

[World95]
Prefix=mi3
Type=Free

[World96]
Prefix=mi4
Type=Free

[World97]
Prefix=mi5
Type=Members

[World98]
Prefix=mi6
Type=Members

[World99]
Prefix=mi7
Type=Members

[World100]
Prefix=ul3
Type=Members

[World101]
Prefix=at7
Type=Free

[World102]
Prefix=at8
Type=Free

[World103]
Prefix=at9
Type=Members

[World104]
Prefix=at10
Type=Members

[World105]
Prefix=mn8
Type=Free

[World106]
Prefix=mn9
Type=Free

[World107]
Prefix=au1
Type=Free

[World108]
Prefix=au2
Type=Free

[World109]
Prefix=au3
Type=Free

[World110]
Prefix=au4
Type=Members

[World111]
Prefix=au5
Type=Members

[World112]
Prefix=au6
Type=Members

[World113]
Prefix=nav4
Type=Free

[World114]
Prefix=nav5
Type=Members

[World115]
Prefix=nav6
Type=Members

[World116]
Prefix=nav7
Type=Members

[World117]
Prefix=swe1
Type=Free

[World118]
Prefix=swe2
Type=Free

[World119]
Prefix=swe3
Type=Free

[World120]
Prefix=swe4
Type=Members

[World121]
Prefix=swe5
Type=Members

[World124]
Prefix=swe8
Type=Members

[World125]
Prefix=va1
Type=Free

[World126]
Prefix=va2
Type=Free

[World127]
Prefix=va3
Type=Free

[World128]
Prefix=va4
Type=Free

[World129]
Prefix=va5
Type=Members

[World130]
Prefix=va6
Type=Members

[World131]
Prefix=va7
Type=Members

[World132]
Prefix=va8
Type=Members

[World133]
Prefix=hel1
Type=Free

[World134]
Prefix=hel2
Type=Free

[World135]
Prefix=hel3
Type=Free

[World136]
Prefix=hel4
Type=Free

[World137]
Prefix=hel5
Type=Members

[World138]
Prefix=hel6
Type=Members

[World141]
Prefix=me1
Type=Free

[World142]
Prefix=me2
Type=Free

[World143]
Prefix=me3
Type=Members

[World144]
Prefix=me4
Type=Members

May be usefull to find prefixes?

Starblaster100

2007-08-22 06:19:07

http://freddy1990.com/fawg.php

YoHoJo

2007-08-22 20:17:58

Anyone get it working yet?
Talked to ben on msn for a bit.
I get it to open rs and the login screen comes up, but srl doesnt seem to login.
The MMouse procedure is also never called, i was wondering if anyone got it going yet?
As for you prefix noobs (ejj :p)
Put Before SetupSRL in the script at the bottom.
SmartSetup('at1',False,False)
SetTargetDC(SmartGetDC)

The Un-Named

2007-08-23 01:59:33

I haven't patched SRL yet, HOWEVER I managed to get it working relatively easy:


var
x, y : Integer;

procedure WMouse(x, y, rx, ry : Integer; click : Boolean);
begin
x := x + Random(rx) - Random(rx);
y := y + Random(ry) - Random(ry);
SmartClickMouse(x, y, click);
end;

procedure SmartLogin(usern, passw : string); //Not very pretty
var existing, clickheret, i, e : Integer;
begin
Wait(Random(1000)); // Avoid clicking asoon as it notices Existing User
existing := BitmapFromString2(False, 'aCCA7878DA9552490EC33' +
'008FC12ADC74B8EB662FEFFA47A8B424449530E23841918C04487' +
'95D42014DF30F2F079EB7E761D0BCE086AF7F7D8D0A59EFF62424' +
'2F6C00EF69985CDDAEB55E31B40FD81068B0D73D53136C995AF66' +
'5CE85FA87248D9CCF1C1C7E0265AAA2EACA1C162AD1CA14177B1F' +
'62CEBAF3D8889CC2E6ADBF7B3C82BFCD1455DFCC9C62EDA8C2EF7' +
'3AAD2D7D9948FF8181F4C026575F61A28E7F00AFF');
clickheret := BitmapFromString2(False, 'aAB9BC78DA9D565B92C' +
'3200CBB129090C767D36DEE7FA40D113B55C691D72D1F1E86806C' +
'CB8A21A53E725D0F3BADC361E7F26CF39D56F2D6E6AFA5D9ADB69' +
'5B5BCE7DBD86CDD9B9DD31B61CE875DD28193D7475B49FB32BDCA' +
'E16CAAC7A7BAD34018BC326DF9995658BBB33E724D1D6DDE8752C' +
'AB8A472454834B0D3F70804E55121F75367469C9DF2A87257EB6A' +
'A89D96437015474646B0E016B1F97E7B5D6A9A528EF08C9D980F5' +
'B1AFE56D8C671147B161F73A5168BCF56E1DB7578515C81D58B3E' +
'033A875D9FE33EFCDCE84720B0FE2F2B8631751631D87A7575894' +
'A29D52177153FE7ABB8955C8948384E5602BCC0A355BBAC85FB9F' +
'DABF9EF17BAF805F57E716874FA9DC238A55BAFD4EE7AACA9C5D5' +
'70BBAA2EA7E547D9C923A71ABC33C289C9BAA19EFDD1ACCB81A55' +
'FCC064A5490D7C7853747D9EF100BFAB9D74DB6F5552BED29EFCE' +
'AC6CCB566FE55CCAA4F4674EE77F2889EED57BF07FA5C5D78F675' +
'4EFDE7639DD359A031E77EFCD6BB55BECF4944FF37AFB833B6C89' +
'DEBBF256EDE36DCD589FFC85DFF4F077675CE675141FF1D12CF31' +
'DECF23D5E1B3CA17EFFC05404');
MarkTime(i);
e := GetBitmapCanvas(existing).Handle;
repeat //Wait until we see "Existing User"
Wait(100);
if TimeFromMark(i) > 120000 then //2 minutes for unsigned
begin
WriteLn('Something bad happened. SmartLogin loop');
TerminateScript;
end;
until SmartFindBitmap(e, x, y);
FreeBitmap(existing);
e := GetBitmapCanvas(clickheret).Handle;

WMouse(x, y, 3, 3, True);
SmartSendKeys(usern + Chr(10) + passw);
WMouse(302, 323, 4, 4, True);

MarkTime(i);

repeat //Wait until we see "Click here to play"
Wait(100);
if TimeFromMark(i) > 120000 then //2 minutes for unsigned
begin
WriteLn('Something bad happened. SmartLogin loop 2');
TerminateScript;
end;
until SmartFindBitmap(e, x, y);
FreeBitmap(clickheret);

WMouse(x, y, 4, 4, True);
end;

begin
SmartSetup('nav4', False, True);
SetTargetDC(SmartGetDC);

while not(SmartReady) do
Wait(100);

SmartLogin('', '');
end.

YoHoJo

2007-08-23 02:41:47

You shouldnt have to make any of your own procedures.
Just use the SMART ones to overwrite SRLS mmouse, typing, holdmouse ect.

The Un-Named

2007-08-23 02:44:29

From: YoHoJo
You shouldnt have to make any of your own procedures.
Just use the SMART ones to overwrite SRLS mmouse, typing, holdmouse ect.


I see, but then you need to manually edit EVERY procedure/function that uses bitmaps. :\

From: BenLand100
Please note that they do not (as of yet ;)) support scar bitmaps, you must pass the dc of the bitmap which is retrieved via GetBitmapCanvas(bmp).Handle;


And if I remember correctly, SRL's login procedures uses text finding, that I assume using bitmaps in SCAR, so you also need to rewrite every procedure/function that uses text.

Sumilion

2007-08-23 05:09:32

From: The Un-Named
I see, but then you need to manually edit EVERY procedure/function that uses bitmaps. :\


No you don't…. smarts bitmaps are just faster, normal findbitmaps should work on smart.

BenLand100

2007-08-23 15:48:23

From: Sumilion
No you don't…. smarts bitmaps are just faster, normal findbitmaps should work on smart.

As they do, thats why you set the target to smart. The searching procedures are just faster than Scar's, you never have to use them. However, it is nice to know that they actually work :) Also, there is no reason to patch SRL if you read the tutorial, just include those procedures (MoveMouse, KeyDown, GetMousePos, etc.) first (above SRL) in you're script.

Smartzkid

2007-08-23 16:12:12

I got my powercutter to work, it was just really laggy; mouse movements weren't too great either, SmartWindMouse helps a lot, though.

Wizzup?

2007-08-24 17:08:29

From: The Un-Named
I see, but then you need to manually edit EVERY procedure/function that uses bitmaps. :\


Function GetColor(x, y:Integer): Integer;

begin
result := smartgetcolor(x, y);
end;
etc.

YoHoJo

2007-08-24 19:19:31

Grr un named
You have everything wrong.
Nothing really needs to be edited at all.
You just use the SMART procedures, and override the ones he posted.
We have SmartFindBitmap ect ect
And for comon procedures just copy/paste what benland posted like
Procedure MoveMouse(x,y:integer)
Begin
SmartMoveMouse(x,y)
end
=)

Wizzup?

2007-08-25 04:58:55

Benland, what about other commonly used functions, I am in desperate need of FindColorsTolerance. x)

WhoCares357

2007-09-15 15:04:27

So this component to Scar uses Java code to redo "Scar" procedures faster and more proficiently? Is there anything special other than that about "SMART"?

Thanks for answering in advance.

Wizzup?

2007-09-15 16:38:32

From: WhoCares357
So this component to Scar uses Java code to redo "Scar" procedures faster and more proficiently? Is there anything special other than that about "SMART"?

Thanks for answering in advance.


Smart = Offscreen color finding and undetetable silent mouse.
Minimizeable.

WhoCares357

2007-09-16 14:28:22

From: Wizzup?
Smart = Offscreen color finding and undetetable silent mouse.
Minimizeable.


Ah. I am hooked :D.