Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SRL/OSR.simba}
- // ----------------------------------------------------------------------------
- // Searches for the number boxes for a ceritan amount of time
- function TRSPinScreen.FindButtons(out Buttons: TBoxArray; SearchTime: Int32): Boolean;
- var
- i: Int32;
- TPA: TPointArray;
- ATPA: T2DPointArray;
- t: TCountDown;
- begin
- t.Init(SearchTime);
- repeat
- if srl.FindColors(TPA, CTS2(988769, 10, 0.06, 1.28), MainScreen.GetBounds) then
- begin
- ATPA := TPA.Cluster(4);
- ATPA.FilterDimensions(45,45, 70,70);
- for i:=0 to High(ATPA) do
- Buttons += ATPA[i].Bounds();
- if (Length(Buttons) >= 10) then
- Exit(True);
- end;
- until t.IsFinished();
- end;
- // ----------------------------------------------------------------------------
- // Sorts the boxes, so that box[0] contains the number 0, and so on
- // will wait for 4 seconds, or until the text appears
- function TRSPinScreen.SortButtons(var Buttons: TBoxArray; SearchTime: Int32): Boolean;
- var
- i,j,count: Int32;
- p: TPoint;
- TBA: TBoxArray;
- _: TPointArray;
- t: TCountDown;
- begin
- TBA := Copy(Buttons);
- Buttons := [];
- // wait for text to appear in the boxes
- t.Init(SearchTime);
- repeat
- count := 0;
- for i:=0 to High(TBA) do
- if (srl.FindColors(_, CTS1(32767,16), TBA[i]) > 0) then
- Inc(count);
- Wait(100,150);
- until t.IsFinished() or (count >= 9);
- // ensure that we found acceptable amount of pixels
- if (count < 9) then
- Exit(False);
- // now order the boxes so that Buttons[4] is the button for the number 4, and so on.
- SetLength(Buttons, 10);
- count := 0;
- for i:=0 to 9 do
- for j:=0 to High(TBA) do
- if srl.FindText(p, ToStr(i), 'UpChars07_s', 32767, 16, TBA[j].ExpandFunc(4)) then
- begin
- Buttons[i] := TBA[j];
- TBA.Del(j);
- Inc(count);
- Break;
- end;
- // if the mouse is over a number, it will disappear, this trick "guesses it"
- for i:=0 to 9 do
- if (TBA <> []) and (Buttons[i] = []) then
- begin
- Buttons[i] := TBA[0];
- Inc(count);
- Break;
- end;
- // only return true if 10 numbers was added
- Result := (count = 10);
- end;
- // ----------------------------------------------------------------------------
- // Debugging is always nice to have, and exists within the various interfaces
- procedure TRSPinScreen.Debug();
- var
- i: Int32;
- buttons: TBoxArray;
- muf: TMufasaBitmap;
- begin
- muf := GetMufasaBitmap(BitmapFromClient(srl.DefaultClientBounds));
- FindButtons(buttons, Random(3000,4500));
- SortButtons(buttons, Random(4000,6500));
- for i:=0 to High(buttons) do
- begin
- muf.DrawBox(buttons[i], False, $00FF00);
- muf.DrawText(ToStr(i), Point(buttons[i].X1+5, buttons[i].Y1+5), $00FF00);
- end;
- muf.Debug();
- end;
- // ----------------------------------------------------------------------------
- // Select that one key
- function TRSPinScreen.SelectKey(x: Int32): Boolean;
- var
- i: Int32;
- buttons: TBoxArray;
- begin
- if (not FindButtons(buttons, Random(3000,4500))) then
- Exit(srl.WriteLn('Pinscreen.FindButtons Failed', False));
- if (not SortButtons(buttons, Random(4000,6500))) then
- Exit(srl.WriteLn('Pinscreen.SortButtons Failed', False));
- Mouse.Move(buttons[x]);
- Wait(90, 1000, wdLeft);
- Mouse.Click(buttons[x], MOUSE_LEFT);
- //if Random(4) = 0 then
- //begin
- // Wait(50,120);
- // Mouse.Move(buttons[Random(10)]);
- // Wait(460, 1400, wdLeft);
- //end;
- Result := True;
- end;
- // ----------------------------------------------------------------------------
- // Input the given pin sequence
- function TRSPinScreen.InputPin(pin: String): Boolean;
- var
- i: Int32;
- b: TBoxArray;
- t: TCountDown;
- p: TPoint;
- atStage: Boolean;
- stages: TStringArray = ['First', 'Now', 'Time', 'Finally'];
- begin
- for i:=0 to High(stages) do
- begin
- atStage := False;
- t.Init(Random(3500, 5000));
- while(not t.IsFinished()) do
- if (atStage := srl.FindText(p, stages[i], 'UpChars07_s', Box(100, 80, 380, 100))) then
- Break;
- if (not atStage) or (not SelectKey(StrToInt(pin[i+1]))) then
- Exit(False);
- Wait(90,1000, wdLeft);
- end;
- Result := True;
- end;
- begin
- WriteLn PinScreen.InputPin('1234'); //set your pin, and run
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement