Skip to content

Update ClearInput to clear input field more effectively#173

Merged
Torwent merged 1 commit intoWaspScripts:mainfrom
XxXAdvisaryXxX:patch-15
May 2, 2026
Merged

Update ClearInput to clear input field more effectively#173
Torwent merged 1 commit intoWaspScripts:mainfrom
XxXAdvisaryXxX:patch-15

Conversation

@XxXAdvisaryXxX
Copy link
Copy Markdown
Contributor

Without the loop it would hit the key once sleep for 6 seconds, key up and thats it.

Now it deletes the characters until all characters are deleted. Part of a two part fix to legacy client and keyboad. Heres a test snippet with the overrides. Run on any legacy client login screen.

{$I Wasplib/osrs.simba}   

procedure TKeyboard.Send(text: String); override;
var
  i: Integer;
begin
  for i := 1 to Length(text) do
  begin
    Target.KeySend(text[i]);
    Sleep(Random(Target.Options.KeyPressMin+80, Target.Options.KeyPressMax+80));
  end;

  Self.LastKey := Target.KeyCodeFromChar(text[Length(text)]);
end;

function TRSLogin.ClearInput(field: ERSLoginInput): Boolean; override;
begin
  if not Self.InputIsFilled(field) then Exit(True);
  if not Self.SelectInput(field) then Exit;

  while self.InputIsFilled(field) do
  Keyboard.KeyPress(EKeyCode.BACK);

  Result := SleepUntil(not Self.InputIsFilled(field), RandomMode(100, 50, 1500),  6000);
  Keyboard.KeyUp(EKeyCode.BACK);
end;

begin
  while true do
  begin
    Login.FillInput(ERSLoginInput.USERNAME , 'Two Four Six Eight');
    Sleep(1000);
    Login.ClearInput(ERSLoginInput.USERNAME);
  end;
end; ```

Without the loop it would hit the key once sleep for 6 seconds, key up and thats it.

Now it deletes the characters until all characters are deleted. Part of a two part fix to legacy client and keyboad. Heres a test snippet with the overrides. Run on any legacy client login screen. 

```Pascal
{$I Wasplib/osrs.simba}   

procedure TKeyboard.Send(text: String); override;
var
  i: Integer;
begin
  for i := 1 to Length(text) do
  begin
    Target.KeySend(text[i]);
    Sleep(Random(Target.Options.KeyPressMin+80, Target.Options.KeyPressMax+80));
  end;

  Self.LastKey := Target.KeyCodeFromChar(text[Length(text)]);
end;

function TRSLogin.ClearInput(field: ERSLoginInput): Boolean; override;
begin
  if not Self.InputIsFilled(field) then Exit(True);
  if not Self.SelectInput(field) then Exit;

  while self.InputIsFilled(field) do
  Keyboard.KeyPress(EKeyCode.BACK);

  Result := SleepUntil(not Self.InputIsFilled(field), RandomMode(100, 50, 1500),  6000);
  Keyboard.KeyUp(EKeyCode.BACK);
end;

begin
  while true do
  begin
    Login.FillInput(ERSLoginInput.USERNAME , 'Two Four Six Eight');
    Sleep(1000);
    Login.ClearInput(ERSLoginInput.USERNAME);
  end;
end; ```
@XxXAdvisaryXxX
Copy link
Copy Markdown
Contributor Author

Here's another snippet with Login.DoLogin(). Make a test profile to test with profiles as well.

{$I Wasplib/osrs.simba}   
procedure TKeyboard.Send(text: String); override;
var
  i: Integer;
begin
  for i := 1 to Length(text) do
  begin
    Target.KeySend(text[i]);
    Sleep(Random(Target.Options.KeyPressMin+80, Target.Options.KeyPressMax+80));
  end;

  Self.LastKey := Target.KeyCodeFromChar(text[Length(text)]);
end;

function TRSLogin.ClearInput(field: ERSLoginInput): Boolean; override;
begin
  if not Self.InputIsFilled(field) then Exit(True);
  if not Self.SelectInput(field) then Exit;

  while self.InputIsFilled(field) do
  Keyboard.KeyPress(EKeyCode.BACK);

  Result := SleepUntil(not Self.InputIsFilled(field), RandomMode(100, 50, 1500),  6000);
  Keyboard.KeyUp(EKeyCode.BACK);
end;

procedure init();
var
  form: TScriptForm;
  tab: TLazTabSheet;
begin
  form.Setup();
  form.CreateMiscTab();
  tab := form.CreateTab('My Settings');
  form.Run();
end;
begin
  Init();
  Login.DoLogin();
end; ```

@Torwent Torwent merged commit 57f6c40 into WaspScripts:main May 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants