Class InputDialog

java.lang.Object
com.botwithus.bot.api.input.InputDialog

public final class InputDialog extends Object
The game's input dialog (MESLAYER, interface 1469): the prompt behind withdraw-X, deposit-X, add-friend and the like. Obtain via api.inputDialog().

Typing goes through the key (type-10) trigger on the dialog's input field, component 4. It does not go through the root, component 0, which carries no triggers. That trigger exists only while the dialog is open, so a stroke fired at a closed dialog is dropped rather than failing.

if (api.bank().startWithdrawX(itemId) && wait.until(api.inputDialog()::isOpen)) {
    api.inputDialog().enterAmount(28);        // types "28", then Enter
}

Failure

Four kinds of failure, each reported its own way. In the first three nothing is sent:
  • Wrong state returns false. The dialog is closed; it is open in a mode the call does not type into; or it already holds text that the new input would push past the mode's limits (the dialog appends). This is a race a script can lose and retry.
  • Input the dialog would refuse throws IllegalArgumentException: too long, a character the mode does not accept, a misplaced suffix, or an amount above MAX_AMOUNT_VALUE. Sending it would type a truncated or different value, so it is refused here rather than left to the game.
  • A failed read of the dialog's mode or text propagates the transport's exception. It is never taken as "closed". One limit: the agent answers a varc read that found nothing with -1, the same value the mode holds before any dialog has opened. A read that timed out inside the agent therefore reads as InputMode.CLOSED, which sends nothing.
  • A partial batch throws IllegalStateException. The agent's action queue took only a prefix of the strokes, so some of them were sent, and the dialog may hold a partial value without its Enter.

Timing

Each call is one action-queue round-trip, but the agent dispatches one stroke per game tick: enterAmount("250k") lands five ticks later (four characters and Enter). A true return means queued, not typed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The dialog's input field, which carries the key trigger (MESLAYER__MES_TEXT2).
    static final int
    The input-dialog interface (MESLAYER).
    static final int
    Longest value amount mode accepts, suffix included.
    static final long
    Largest value amount mode takes, after suffix expansion.
    static final int
    Longest value name mode accepts.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    backspace(int n)
    Press Backspace n times, one per tick, in one batch.
    boolean
    Press Escape, closing the dialog.
    boolean
    Delete everything typed so far: one Backspace per character of text(), so it takes that many ticks.
    boolean
    enterAmount(long amount)
    Type amount and submit it.
    boolean
    Type amount and submit it.
    boolean
    Type text and submit it.
    boolean
    True while an input dialog of any mode is open.
    What the dialog is asking for; InputMode.CLOSED when it is not open.
    boolean
    Press Enter.
    The text typed so far, or empty when the dialog is closed.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INTERFACE_ID

      public static final int INTERFACE_ID
      The input-dialog interface (MESLAYER).
      See Also:
    • INPUT_COMPONENT

      public static final int INPUT_COMPONENT
      The dialog's input field, which carries the key trigger (MESLAYER__MES_TEXT2).
      See Also:
    • MAX_AMOUNT_LENGTH

      public static final int MAX_AMOUNT_LENGTH
      Longest value amount mode accepts, suffix included.
      See Also:
    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      Longest value name mode accepts.
      See Also:
    • MAX_AMOUNT_VALUE

      public static final long MAX_AMOUNT_VALUE
      Largest value amount mode takes, after suffix expansion.
      See Also:
  • Constructor Details

    • InputDialog

      public InputDialog(GameAPI api)
  • Method Details

    • mode

      public InputMode mode()
      What the dialog is asking for; InputMode.CLOSED when it is not open. One RPC.
    • isOpen

      public boolean isOpen()
      True while an input dialog of any mode is open. One RPC.
    • text

      public Optional<String> text()
      The text typed so far, or empty when the dialog is closed. The variable behind it keeps its last value after the dialog closes, so it is only read while a dialog is open. Two RPCs.
    • enterAmount

      public boolean enterAmount(long amount)
      Type amount and submit it. Needs the dialog open in InputMode.AMOUNT.
      Returns:
      false, sending nothing, when the dialog is not in amount mode, or it already holds text that amount would push past the limits
      Throws:
      IllegalArgumentException - when amount is negative or above MAX_AMOUNT_VALUE
    • enterAmount

      public boolean enterAmount(String amount)
      Type amount and submit it. Accepts digits with an optional suffix after at least one digit: k/K for thousands or m/M for millions, such as "250", "10k" or "2M". The limits are MAX_AMOUNT_LENGTH characters in all and MAX_AMOUNT_VALUE once the suffix is expanded. Needs the dialog open in InputMode.AMOUNT. After a submit, the dialog's text variable holds the expanded digits ("1M" reads back as "1000000").

      The dialog appends to whatever it already holds, so the check also applies to the existing text() followed by amount. clear() first to replace it.

      Returns:
      false, sending nothing, when the dialog is not in amount mode, or it already holds text that amount would push past the limits
      Throws:
      IllegalArgumentException - when amount on its own is not a value amount mode accepts ("b", "1.5k", "k5", "5kk", "M5", "2148m", blank, too long)
    • enterText

      public boolean enterText(String text)
      Type text and submit it. Accepts letters, digits, space and _-.!, case kept, up to MAX_NAME_LENGTH characters. Needs the dialog open in InputMode.NAME. Other text modes have no verified limits, so they are refused rather than guessed at; drive those with GameAPI.fireKeys(int, int, List) directly.

      As with enterAmount(String), the check also applies to the existing text() followed by text.

      Returns:
      false, sending nothing, when the dialog is not in name mode, or it already holds text that text would push past the limit
      Throws:
      IllegalArgumentException - when text is blank, too long, or holds a character name mode does not accept
    • submit

      public boolean submit()
      Press Enter. false, sending nothing, when no dialog is open.
    • cancel

      public boolean cancel()
      Press Escape, closing the dialog. false, sending nothing, when none is open.
    • backspace

      public boolean backspace(int n)
      Press Backspace n times, one per tick, in one batch. false, sending nothing, when no dialog is open. true with nothing sent when n is 0. clear() is the call for "delete everything".
      Throws:
      IllegalArgumentException - when n is negative
    • clear

      public boolean clear()
      Delete everything typed so far: one Backspace per character of text(), so it takes that many ticks. false, sending nothing, when no dialog is open; true with nothing sent when it is already empty.