SRL Archive - SRL Suggestions

Fixed InPin and added new function ClosePinScreen;


Gu3st...

2011-02-23 16:52:48

The old one was poorly written, outdated (boxes were off by some pixels) and JaGeX has updated they're pin screens to update faster (Meaning the current InPin is rather slow).

And this new version doesn't move the mouse in-between the clicks.
function ClosePinScreen: Boolean;
var
Timer : Integer;
begin
Result := False;
Timer := GetSystemTime + 10000;
while PinScreen do
begin
if Timer > GetSystemTime then
Break;
MouseBox(332, 258, 489, 281, 1);
Wait(500);
end;
Result := not PinScreen;
end;

function InPin(Pin: string): Boolean;
var
Tx, Ty, X, Y, H, I, J, Tries : Integer;
Boxes: array of TBox;
begin
Result := False;
if not PinScreen then Exit;

if (GetNumbers(Pin) <> Pin) then
begin
srl_Warn('InPin', '''' + Pin + ''' is not a valid Pin', warn_AllVersions);
Exit;
end;
if (Length(Pin) <> 4) then
begin
srl_Warn('InPin', 'Pin must be 4 digits long', warn_AllVersions);
Exit;
end;

Boxes := [IntToBox(37, 107, 100, 170), IntToBox(127, 107, 190, 170), IntToBox(217, 107, 280, 170), IntToBox(307, 107, 370, 170),
IntToBox(37, 179, 100, 242), IntToBox(127, 179, 190, 242), IntToBox(217, 179, 280, 242),
IntToBox(37, 251, 100, 314), IntToBox(127, 251, 190, 314), IntToBox(217, 251, 280, 314)];

while PinScreen do
begin
for I := 1 to 4 do
begin
if not PinScreen then Break;
GetMousePos(X, Y);
if (FindText(Tx, Ty, Pin[I], UpChars, 30, 100, 383, 319)) then
begin
H := High(Boxes);
for J := 0 to H do
if IntInBox(Tx, Ty, Boxes[J]) then
begin
with Boxes[J] do
if PinScreen then
MouseBox(x1, y1, x2, y2, 1);
Break;
end;
end else
begin
H := High(Boxes);
for J := 0 to H do
if IntInBox(X, Y, Boxes[J]) then
begin
with Boxes[J] do
if PinScreen then
MouseBox(x1, y1, x2, y2, 1);
Break;
end;
end;

Wait(200+Random(100)); // Had to add a wait here because humans aren't that fast.

if BankScreen then
begin
Result := True;
Exit;
end;
end;

WaitFunc(@BankScreen, 50, 300);

ClickContinue(True, True);
while not FindColor(Tx, Ty, 0, 7, 460, 69, 474) do
begin
Wait(500);
if not LoggedIn then
Exit;
end;
Inc(Tries);

if Tries > 2 then
begin
srl_Warn('InPin', '''' + Pin + ''' is not the correct Pin', warn_AllVersions);
ClosePinScreen;
Exit;
end;

end;
Result := BankScreen;
end;

Train

2011-02-23 16:58:17

Does it click the box it's currently on if it doesn't find the number?

Gu3st...

2011-02-23 16:58:47

From: Train
Does it click the box it's currently on if it doesn't find the number?
Yep

ZephyrsFury

2011-02-23 21:05:34

Isn't there a CloseWindow function that closes the Pin screen?

Wanted

2011-02-23 23:47:55

InPin has been pissing me off for a while now.

I've been meaning to rewrite it, but never got around to it.

I put this in my SRL folder and am going to see if its fine as is or if it needs to be tweaked or whatever.

The reason for that is that I looked at the diff and it seems to be a bit different than the current InPin.

Harry

2011-02-24 00:09:41

Yeah, the pin was changed in a recent update (less than 3 weeks ago, I think). Entirely client-side entering, and only sends the pin to the server to verify after all four numbers are entered correctly.

Just curious (don't have time to read it right now), does it move the mouse to a random spot after clicking still? Maybe it could keep where the button is, and if it doesn't find the number, THEN move the mouse and click the proper one?

Wanted

2011-02-24 01:01:46

Went ahead and committed this by accident actually.

I'll add the proper credits/headers next commit.

If there's any problem I'll revert/fix, but appears to be working great.

Gu3st...

2011-02-24 15:45:38

From: Harry
Just curious (don't have time to read it right now), does it move the mouse to a random spot after clicking still? Maybe it could keep where the button is, and if it doesn't find the number, THEN move the mouse and click the proper one?
No random movement :)
If it finds the number, then it moves the mouse to that button and clicks it, if it does not find the number then it checks to see if it is hovering any of the buttons, and if it does, it clicks that button.

From: IceFire908
Went ahead and committed this by accident actually.

I'll add the proper credits/headers next commit.

If there's any problem I'll revert/fix, but appears to be working great.
Thanks :)