Class InputDialog
java.lang.Object
com.botwithus.bot.api.input.InputDialog
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 aboveMAX_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 asInputMode.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
FieldsModifier and TypeFieldDescriptionstatic final intThe dialog's input field, which carries the key trigger (MESLAYER__MES_TEXT2).static final intThe input-dialog interface (MESLAYER).static final intLongest value amount mode accepts, suffix included.static final longLargest value amount mode takes, after suffix expansion.static final intLongest value name mode accepts. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbackspace(int n) Press Backspacentimes, one per tick, in one batch.booleancancel()Press Escape, closing the dialog.booleanclear()Delete everything typed so far: one Backspace per character oftext(), so it takes that many ticks.booleanenterAmount(long amount) Typeamountand submit it.booleanenterAmount(String amount) Typeamountand submit it.booleanTypetextand submit it.booleanisOpen()True while an input dialog of any mode is open.mode()What the dialog is asking for;InputMode.CLOSEDwhen it is not open.booleansubmit()Press Enter.text()The text typed so far, or empty when the dialog is closed.
-
Field Details
-
INTERFACE_ID
public static final int INTERFACE_IDThe input-dialog interface (MESLAYER).- See Also:
-
INPUT_COMPONENT
public static final int INPUT_COMPONENTThe dialog's input field, which carries the key trigger (MESLAYER__MES_TEXT2).- See Also:
-
MAX_AMOUNT_LENGTH
public static final int MAX_AMOUNT_LENGTHLongest value amount mode accepts, suffix included.- See Also:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHLongest value name mode accepts.- See Also:
-
MAX_AMOUNT_VALUE
public static final long MAX_AMOUNT_VALUELargest value amount mode takes, after suffix expansion.- See Also:
-
-
Constructor Details
-
InputDialog
-
-
Method Details
-
mode
What the dialog is asking for;InputMode.CLOSEDwhen it is not open. One RPC. -
isOpen
public boolean isOpen()True while an input dialog of any mode is open. One RPC. -
text
-
enterAmount
public boolean enterAmount(long amount) Typeamountand submit it. Needs the dialog open inInputMode.AMOUNT.- Returns:
false, sending nothing, when the dialog is not in amount mode, or it already holds text thatamountwould push past the limits- Throws:
IllegalArgumentException- whenamountis negative or aboveMAX_AMOUNT_VALUE
-
enterAmount
Typeamountand submit it. Accepts digits with an optional suffix after at least one digit:k/Kfor thousands orm/Mfor millions, such as"250","10k"or"2M". The limits areMAX_AMOUNT_LENGTHcharacters in all andMAX_AMOUNT_VALUEonce the suffix is expanded. Needs the dialog open inInputMode.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 byamount.clear()first to replace it.- Returns:
false, sending nothing, when the dialog is not in amount mode, or it already holds text thatamountwould push past the limits- Throws:
IllegalArgumentException- whenamounton its own is not a value amount mode accepts ("b","1.5k","k5","5kk","M5","2148m", blank, too long)
-
enterText
Typetextand submit it. Accepts letters, digits, space and_-.!, case kept, up toMAX_NAME_LENGTHcharacters. Needs the dialog open inInputMode.NAME. Other text modes have no verified limits, so they are refused rather than guessed at; drive those withGameAPI.fireKeys(int, int, List)directly.As with
enterAmount(String), the check also applies to the existingtext()followed bytext.- Returns:
false, sending nothing, when the dialog is not in name mode, or it already holds text thattextwould push past the limit- Throws:
IllegalArgumentException- whentextis 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 Backspacentimes, one per tick, in one batch.false, sending nothing, when no dialog is open.truewith nothing sent whennis0.clear()is the call for "delete everything".- Throws:
IllegalArgumentException- whennis negative
-
clear
public boolean clear()Delete everything typed so far: one Backspace per character oftext(), so it takes that many ticks.false, sending nothing, when no dialog is open;truewith nothing sent when it is already empty.
-