Package rs.kreme.ksbot.api.hooks
Class Widgets
- java.lang.Object
-
- rs.kreme.ksbot.api.hooks.Widgets
-
public class Widgets extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Widgets()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description KSWidgetgetChildContains(KSWidget parent, java.lang.String text)Finds a child widget in a parent that contains the specified text.java.util.List<KSWidget>getChildWithOffset(KSWidget parent, int startIndex, int offset)Retrieves child widgets at a given offset.java.util.List<KSItem>getItems(KSWidget widget)Retrieves the list of items from a widget.KSWidgetgetWidget(int componentId)Retrieves a widget by its component ID.KSWidgetgetWidget(int[] widgetId)Retrieves a widget by its ID.KSWidgetgetWidget(int groupId, int childId)Retrieves a widget using a group and child ID.KSWidgetgetWidget(int groupId, int childId, int index)Retrieves a child widget from a parent using group, child, and index.KSWidgetgetWidget(net.runelite.api.widgets.WidgetInfo widgetInfo)Retrieves a widget by its WidgetInfo.voidinteract(int widgetId)Deprecated.voidinteract(int widgetId, int index, int option)Deprecated.voidinteract(KSWidget widget, int option)Deprecated.voidinteract(KSWidget widget, int option, int index)Interacts with a widget using the specified option and index.voidinteract(KSWidget widget, net.runelite.api.MenuAction menuAction, int index, int option)Deprecated.booleanisUsable(int widget)booleanisUsable(net.runelite.api.widgets.WidgetInfo widget)booleanisUsable(KSWidget widget)Checks if a widget is usable (i.e., not hidden).booleanisUsable(KSWidget widget, java.util.function.Predicate<? super KSWidget> predicate)Checks if a widget is usable and satisfies a given predicate.intPACK(int groupId, int childId)Packs group and child IDs into a single ID.WidgetQueryquery()Searches for all widgets in the game.intTO_CHILD(int id)Converts an ID to its child part.intTO_GROUP(int id)Converts an ID to its group part.
-
-
-
Method Detail
-
query
public WidgetQuery query()
Searches for all widgets in the game.- Returns:
- A WidgetQuery containing all widgets in the client.
-
getWidget
public KSWidget getWidget(int[] widgetId)
Retrieves a widget by its ID.- Parameters:
widgetId- An array representing group and child ID.- Returns:
- The corresponding widget or null if not found.
-
getWidget
public KSWidget getWidget(int groupId, int childId)
Retrieves a widget using a group and child ID.- Parameters:
groupId- The group ID of the widget.childId- The child ID of the widget.- Returns:
- The corresponding widget or null if not found.
-
getWidget
public KSWidget getWidget(int groupId, int childId, int index)
Retrieves a child widget from a parent using group, child, and index.- Parameters:
groupId- The group ID of the widget.childId- The child ID of the widget.index- The index of the child.- Returns:
- The child widget or null if not found.
-
isUsable
public boolean isUsable(KSWidget widget)
Checks if a widget is usable (i.e., not hidden).- Parameters:
widget- The widget to check.- Returns:
- True if the widget is usable, false otherwise.
-
isUsable
public boolean isUsable(net.runelite.api.widgets.WidgetInfo widget)
-
isUsable
public boolean isUsable(int widget)
-
isUsable
public boolean isUsable(KSWidget widget, java.util.function.Predicate<? super KSWidget> predicate)
Checks if a widget is usable and satisfies a given predicate.- Parameters:
widget- The widget to check.predicate- A condition to test on the widget.- Returns:
- True if the widget is usable and matches the predicate, false otherwise.
-
TO_GROUP
public int TO_GROUP(int id)
Converts an ID to its group part.- Parameters:
id- The widget ID.- Returns:
- The group part of the ID.
-
TO_CHILD
public int TO_CHILD(int id)
Converts an ID to its child part.- Parameters:
id- The widget ID.- Returns:
- The child part of the ID.
-
PACK
public int PACK(int groupId, int childId)Packs group and child IDs into a single ID.- Parameters:
groupId- The group ID.childId- The child ID.- Returns:
- A packed widget ID.
-
getWidget
public KSWidget getWidget(net.runelite.api.widgets.WidgetInfo widgetInfo)
Retrieves a widget by its WidgetInfo.- Parameters:
widgetInfo- The WidgetInfo of the widget.- Returns:
- The corresponding widget or null if not found.
-
getWidget
public KSWidget getWidget(int componentId)
Retrieves a widget by its component ID.- Parameters:
componentId- The component ID.- Returns:
- The corresponding widget or null if not found.
-
getChildContains
public KSWidget getChildContains(KSWidget parent, java.lang.String text)
Finds a child widget in a parent that contains the specified text.- Parameters:
parent- The parent widget.text- The text to search for.- Returns:
- The child widget containing the text or null if not found.
-
getChildWithOffset
public java.util.List<KSWidget> getChildWithOffset(KSWidget parent, int startIndex, int offset)
Retrieves child widgets at a given offset.- Parameters:
parent- The parent widget.startIndex- The start index.offset- The offset between each child.- Returns:
- A list of child widgets.
-
getItems
public java.util.List<KSItem> getItems(KSWidget widget)
Retrieves the list of items from a widget.- Parameters:
widget- The widget to get items from.- Returns:
- A list of KSItem objects representing the items in the widget.
-
interact
public void interact(KSWidget widget, int option, int index)
Interacts with a widget using the specified option and index.- Parameters:
widget- The widget to interact with.option- The option to select.index- The index of the widget.
-
interact
@Deprecated public void interact(int widgetId)
Deprecated.Interacts with a widget.- Parameters:
widgetId- The widget id to interact with.
-
interact
@Deprecated public void interact(int widgetId, int index, int option)Deprecated.Interacts with a widget based on its ID, index, and option.- Parameters:
widgetId- The ID of the widget to interact with.index- The index of the interaction option.option- The specific option to select for the interaction.
-
interact
@Deprecated public void interact(KSWidget widget, net.runelite.api.MenuAction menuAction, int index, int option)
Deprecated.Interacts with a widget using a specified menu action, index, and option.- Parameters:
widget- The widget to interact with.menuAction- The type of menu action.index- The index of the widget.option- The option to select.
-
interact
@Deprecated public void interact(KSWidget widget, int option)
Deprecated.Interacts with a widget using the specified option.- Parameters:
widget- The widget to interact with.option- The option to select.
-
-