Class Widgets

java.lang.Object
privbot.hooks.Widgets

public final class Widgets extends Object
Interface widgets: ctx.widgets (find by id or visible text, read text, click options).

On Impact, Elorin and SpawnPK a widget's hidden flag can lie for interfaces that closed; where the client can tell which interfaces it is drawing, visibility reads ask it instead. Interactions return dispatch acceptance; verify the interface changed.

  • Method Details

    • query

      public WidgetQuery query()
      Empty widget query — add WidgetQuery.root(int) / WidgetQuery.expandImmediateChildren() as needed.
    • queryAt

      public WidgetQuery queryAt(int packedRootId)
      Query the widget at this inspector packed id (group.child) plus its immediate child layer. Typical use: widgets.queryAt(id).withNonEmptyName().first() or .withItemOrName().first().
    • getByInspectorPath

      public net.runelite.api.widgets.Widget getByInspectorPath(String path)
      Resolves a widget using inspector path syntax (e.g. 774.52[5]) when the packed parent id is ambiguous or the click target is a nested child — same rules as TransportRequest.WidgetPathStep.widgetInspectorPath.
    • interactInspectorPath

      public boolean interactInspectorPath(String path, String option)
    • isHidden

      public boolean isHidden(int packedId)
      Whether the widget at packedId is missing or hidden. Safe from any thread (dispatches to the client thread).
    • isHidden

      public boolean isHidden(int groupId, int childId)
      Parameters:
      groupId - the interface group
      childId - the child
      Returns:
      whether the widget is missing or hidden (true when unreadable)
    • isVisible

      public boolean isVisible(int packedId)
      Inverse of isHidden(int) — false when missing, hidden, or thread dispatch fails.
    • childTextLower

      public String childTextLower(int parentPackedId, int childIndex)
      Lowercase text from client.getWidget(parentPackedId).getChild(childIndex) when the parent is non-hidden; otherwise empty string. Client access runs on the game thread.
    • hasText

      public boolean hasText(String text)
      Parameters:
      text - a substring, case-insensitive
      Returns:
      whether a visible widget's text contains it
    • hasExactText

      public boolean hasExactText(String text)
      Parameters:
      text - the whole text
      Returns:
      whether a visible widget's text equals it (case-insensitive)
    • find

      public net.runelite.api.widgets.Widget find(String text)
      Parameters:
      text - a substring of a visible widget's text
      Returns:
      the first such widget, or null
    • find

      public net.runelite.api.widgets.Widget find(String text, Widgets.MatchMode mode)
      Parameters:
      text - the text
      mode - how to match it
      Returns:
      the first visible widget whose text matches, or null
    • interactText

      public boolean interactText(String text)
      Clicks the visible widget whose text is exactly text, with that text as the option.
      Parameters:
      text - the widget's text
      Returns:
      dispatch acceptance
    • interactText

      public boolean interactText(String text, String option)
      Parameters:
      text - the widget's exact text
      option - the menu option to use
      Returns:
      dispatch acceptance
    • interactText

      public boolean interactText(String text, String option, Widgets.MatchMode mode)
      Parameters:
      text - the widget's text
      option - the menu option to use ("Continue" also tries a selectable text option)
      mode - how to match text
      Returns:
      dispatch acceptance
    • has

      public boolean has(String query)
      Quiet read for shouldExecute: a visible widget matches query (text, then name, then action, then target verb; exact then contains).
    • interact

      public boolean interact(String query)
      Find a visible widget by text / name / action and click it. true means dispatch was accepted.
    • interact

      public boolean interact(String query, String action)
      Find by query, then click action (name then action).
    • interactConfirmed

      public Widgets.WidgetEffect interactConfirmed(String query, String option, long timeoutMs)
      Clicks like interact(String, String) and then WAITS for the client to show a response: an interface root opening or closing (the server's reply to almost every button — teleport menus, banks, shops, dialogues), the clicked widget disappearing, or a varp changing. This is the confirmation a plugin should gate on before its next step; interact(java.lang.String) alone only proves the click was handed to the client. option may be null for the default option.
    • interactConfirmed

      public Widgets.WidgetEffect interactConfirmed(String query, long timeoutMs)
      Same as interactConfirmed(String, String, long) with the default option.
    • drawnRoots

      public Set<Integer> drawnRoots()
      The interface roots the client is drawing, or null where this server cannot say.
    • interactWithoutSavedLibrary

      public boolean interactWithoutSavedLibrary(net.runelite.api.widgets.Widget widget, String option)
      Like interact(Widget, String) but never consults the saved menu-action library (no saved NamedMenuAction fallback). Use when the caller already resolved the widget by text and must avoid replaying calibrated library entries.
    • interact

      public boolean interact(int packedId, String option)
      Parameters:
      packedId - the widget id
      option - the menu option
      Returns:
      dispatch acceptance; false when the widget does not resolve
    • interact

      public boolean interact(int groupId, int childId, String option)
      Parameters:
      groupId - the interface group
      childId - the child
      option - the menu option
      Returns:
      dispatch acceptance
    • interact

      public boolean interact(net.runelite.api.widgets.Widget widget, String option)
      Clicks option on widget, using a saved menu action for it when one exists.
      Parameters:
      widget - the widget (may be null)
      option - the menu option
      Returns:
      dispatch acceptance
    • interactSimpleByText

      public boolean interactSimpleByText(String textContains, Widgets.MatchMode mode, String option)
      Minimal-parameter widget click for workflows: resolve by visible text, then dispatch using server-appropriate menu shape. On SpawnPK, uses PrivBotSpawnPKWidgetType1Params (SpawnPKMenuInvoker#resolveWidgetType1MenuTuple) when registered so IF3 / target-verb rows work.
    • interactSimpleByWidgetId

      public boolean interactSimpleByWidgetId(int widgetId, String option)
      Minimal-parameter widget click by flat or packed widget id (same client.getWidget lookup as interact(int, String)).