SRL Archive - Outdated Tutorials

Auto-Login


Pwnd

2006-04-11 18:55:01

Dificulty: Easy as hell. Experience with procedures and parameters required. Some mild work with variables as well.

For beginners or people having a hard time for some aspects.

Ok, you want to create your first script, or possibley want some practice? Well, we're going to work on making one of the basic scripts, the auto-login. I will walk you step by step to making an auto-login without using ANY INCLUDE. It's easy, trust me.

First thing's first:
How are we going to move the mouse and click it? Well, I'm going to show you a brief, few procedures.

First, lets make it click0r.

procedure HumanMouse(x, y: integer; Click: boolean);
var
i: integer;
begin
HoldMouse(x, y, Click);
repeat
Wait(10 + Random(10))
i:= i + 1;
until(i = 4)
ReleaseMouse(x, y, Click);
end;
Alright, the parameters are the coords (x and y) that you want to click at and the boolean "Click" is if you want to click the left mouse(True), or the right mouse(False).

From the beginning:
————————–

begin
HoldMouse(x, y, Click);
This will hold the mouse to start off.

————————–

repeat
Wait(10 + Random(10));
i:= i + 1;
until(i = 4)
This will repeat "Wait(10 + Random(10))" four times. "i" is to help count that.

————————–

ReleaseMouse(x, y, Click);
end;
This will release the mouse at its current position and "end;" will end the procedure.

Here is how we're going to move the mouse.
Alright, I'm don't understand MoveMouseSmoothEx to much myself (Parameter wise), but that is what we're going to use.
Firstly:
Make a procedure to move the mouse.

procedure MMouse(x, y: integer);
begin
MoveMouseSmoothEx(x, y, 1, 6, 15, 20, 21);
end;
You may be like, "Well, why do you need to make a new procedure for one thing?" Well, who really wants to type in all of those parameters for MoveMouseSmoothEx? :)

This is used the same way MoveMouse(x, y: integer); would be used, so it is quite easy, infact.

Now, to make EVERYTHING much easier, we're going to combine our mouse method and clicking method into one procedure.

procedure Mouse(x, y, Click: integer);
begin
MMouse(x, y);
GetMousePos(x, y);
case(Click)of
1: HumanMouse(x, y, True);
2: HumanMouse(x, y, False);
0: end;
end;
end;
Alright, what this will do is move the mouse using our MMouse procedure, then, specified by an integer, it will either click the left mouse, right mouse, or not at all.

From the top:

begin
MMouse(x, y);
GetMousePos(x, y);
This will move the mouse, then reset the x and y variables that we declares to the current spot(Which should actually be the same, but sometimes mouse movements can get a little random on us ;)).

———————-

case(Click)of
1: HumanMouse(x, y, True);
2: HumanMouse(x, y, False);
0: end;
end;
Ok, this is how case works. You take a variables, as we did from the parameter, and takes it's name and put it like this: "case(varName)of" Ok, now.. depending on what varName is, can be an integer, string, or boolean, it will do the preceding actions cooresponding to it's name.

So, lets say click in the parameters was 1. It would perform the action after 1: which is HumanMouse(x, y, True);.

Now, if it was 0 in our case.. It would do nothing because after 0: there is an end;. This will stop everything.

and of course the end; for the end of the procedure.

Next thing: Login Screen Detection.
Hopefully you know a little bit about bitmaps(i.e. how to create them). Knowing that you know how to make bitmaps we're going to work on our next concept.

Lets make our bitmap first of all.
We're going to take some text from the login screen.
Here's the image that I used:
You can use it as well.

Welcome := BitmapFromString(22, 1, 'z78DA3330187800006EBE18' +
'C1');
Here's the bitmap string. Lets put that in our script.

So far you should have this:

program AutoLogin;

procedure HumanMouse(x, y: integer; Click: boolean);
var
i: integer;
begin
HoldMouse(x, y, Click);
repeat
Wait(10 + Random(10))
i:= i + 1;
until(i = 4)
ReleaseMouse(x, y, Click);
end;

procedure MMouse(x, y: integer);
begin
MoveMouseSmoothEx(x, y, 1, 6, 15, 20, 21);
end;

procedure Mouse(x, y, Click: integer);
begin
MMouse(x, y);
GetMousePos(x, y);
case(Click)of
1: HumanMouse(x, y, True);
2: HumanMouse(x, y, False);
0: begin
end;
end;

function LoginScreenDetection: boolean;
var
x, y: integer;
Welcom: integer;
begin
Welcome:= BitmapFromString(22, 1, 'z78DA3330187800006EBE18' +
'C1');

Notice how LoginScreenDetection is a boolean function? I'll show you the rest of that method:

function LoginScreenDetection: boolean;
var
x, y: integer;
Welcom: integer;
begin
Welcome:= BitmapFromString(22, 1, 'z78DA3330187800006EBE18' +
'C1');
if(FindBitmap(Welcome, x, y))then
begin
WriteLn('At the login screen');
Result:= True;
end else
begin
WriteLn('Not at the login screen');
Result:= False;
end;
end;

function LoginScreenDetection: boolean;
var
x, y: integer;
Welcom: integer;
begin
Declares the function name and type, and the variables to start.

Welcome:= BitmapFromString(22, 1, 'z78DA3330187800006EBE18' +
'C1');
if(FindBitmap(Welcome, x, y))then
begin
WriteLn('At the login screen');
Result:= True;
Declares what "Welcome" is..
If you find the bitmap Welcome then write line "At the login screen" and set the result to true.

end else
begin
WriteLn('Not at the login screen');
Result:= False;
end;
end;
If you don't find the bitmap then write line "Not at the login screen" and set the result to false.

Ok, now that we have the detection down.. We have to use it some way.. This alone isn't going to log us in, will it?

I'm going to break it into parts as seperate procedures, but you can put most of these together.

procedure Login;
begin
if(LoginScreenDetection = True)then
begin
Mouse(441, 295, 1);
Wait(100);
SendKeys(Username + Chr(13));
Wait(50);
SendKeys(Password);
Wait(100);
Mouse(291, 295, 1);
end else
TerminateScript;
end;
If at the login screen
Click at coords 441 and 295 (The "Login" text)0
Wait a little.
Unsafely type the username and the "Enter" key (Chr(13))
Wait
Again, unsafely type the password.
Wait
Click the "Enter" buton.

If not at the login screen
Stop the script.

This will only get us so far, right? We still need to click on that other red button right before you can play the game.
The bitmap I used.

procedure LoginFinal;
var
Click: integer;
x, y: integer;
begin
Login;
Click:= BitmapFromString(48, 1, 'z78DA33301805F800007DE236' +
'01');
if(FindBitmap(Click, x, y))then
begin
Mouse(x, y, 1);
WriteLn('Woot, logged in');
end;
end;
Declare the variables

Call the login procedure

Define the "Click" variable.

If find bitmap "Click" then
click where the bitmap is.
Write line "Woot, logged in"

Easy enough?

And to top it off; your main loop.

begin
LoginFinal;
end.
This will call the LoginFinal procedure and everything will come together.


I got a little lazy at the end, but you can't blame me ;D

Thanks everyone.

Sdcit

2006-04-11 18:59:30

Great tutorial pwnd :P

Pwnd

2006-04-11 19:00:55

From: Sdcit
Great tutorial pwnd :P

So far it is a tutorial on how to click and move the mouse xD

Neonknight77

2006-04-11 20:35:44

Your video one was better :)

Pwnd

2006-04-13 23:37:22

Finished.. It sucks, but it works.

If my mic worked I'd do the video one, but.. Yeah.

Thanks guys.

WhiteShadow

2006-04-13 23:41:47

  if(LoginScreenDetection = True)then

The "true" is kind of unneeded because it's boolean. But if you think it's more sexy like that leave it. :p

XxKanexX

2006-04-14 00:25:59

From: WhiteShadow
  if(LoginScreenDetection = True)then

The "true" is kind of unneeded because it's boolean. But if you think it's more sexy like that leave it. :p

It's better for explaining what it means in the script. New people might not know what it would do if on its own.

Edit: Pwnd, you made a mouse procedure called "MMouse". But in the script you just use "Mouse", lol.

phantombmx

2006-04-14 01:08:41

lol kane, it works.. he did a humanclick.. then mmouse.. then mouse with mmouse than a humanclick.. look closely ;)

nice tut tho pwnd!! it.. uhh.. pwns.. :D

XxKanexX

2006-04-14 05:13:31

From: phantombmx
lol kane, it works.. he did a humanclick.. then mmouse.. then mouse with mmouse than a humanclick.. look closely ;)

nice tut tho pwnd!! it.. uhh.. pwns.. :D

Oh, dam. ;) I normally just scan some things. Hehe.

Jagex_Fagex

2006-04-14 05:24:50

yer, look spretty good…

Pwnd

2006-04-14 10:23:16

From: XxKanexX
It's better for explaining what it means in the script. New people might not know what it would do if on its own.

Edit: Pwnd, you made a mouse procedure called "MMouse". But in the script you just use "Mouse", lol.

I'm to sexy to make mistakes.

Jimmyjohn

2007-03-03 22:55:43

it doesn't work for me…

pwnaz0r

2007-03-03 23:00:11

… This was made like at the begging of SRL… why ru gravedigging