PDA

View Full Version : How to Add Auto-Login to A Script?



mbuzz13
05-31-2016, 06:00 PM
I'm wondering if there is a way to add an auto-login function to a script in case the server dc's so you do not have to check up on the script as often. If anyone has a snippet, that would be helpful, or if someone could walk me through how to write the code, that would be awesome. Thanks.

Citrus
05-31-2016, 07:08 PM
This is what I used in one of my scripts:

function isLoggedIn(): boolean;
var
x, y: integer;
begin
result := findColor(x, y, 65536, 740, 0, 760, 25);
end;

You can then do something like
while isLoggedIn do mainloop();
as long as your other procedures can't get stuck infinitely.

As for logging in, you can get away with just basic clicking and typing.

honeyhoney
05-31-2016, 08:58 PM
The SRL Include is always going to be a great resource when considering how to tackle issues on private servers.

https://github.com/SRL/SRL/blob/829190b91ddceaf847803c561597791bf0646efb/osr/client.simba#L1

The general idea for getting the login state is to identify a color that is either unique to the login or game screen. Once you have that it's just a simple Find/GetColor as shown in the link above and also by Citrus.

For logging in, http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html should give you some help when it comes to keyboard input.

SendKeys('username', 100, 30); // types out the username
PressKey(13); // hits enter
SendKeys('password', 100, 30); // types out the password
PressKey(13); // hits enter

You will of course want to add checks that the login screen is open, which textbox is currently selected etc.

jstemper
06-01-2016, 02:44 AM
function IsLoggedIn(): boolean;
begin
result := (getColor(401, 436) = 4231423); //some color on the logout screen, pick a color from an area that is static when logged in
end;

begin
if (not isLoggedIn()) then
SomeLoginProcedure();
end.

rj
06-01-2016, 04:37 AM
Following up on jstemper's response if you are using SRL-6 you are going to want to ovvride the isLoggedIn function

function IsLoggedIn(): boolean; override;
begin
result := (getColor(401, 436) = 4231423); //some color on the logout screen, pick a color from an area that is static when logged in
end;