Jump to content

REQUEST: tutorial on understanding widgets


justanotherkid

Recommended Posts

could someone explain the widget api and how to use them? thanks! there currently isn't any resources for understanding them

 

Step 1) Go to settings -> options -> debug -> tick Widgets

 

3dd602bb43.png

 

Step 2) Hover your mouse over the part of the screen you want to be able to interact with using widgets

 

KIqzlZy.png

 

 

In this case, the mouse is hovering over the skills tab. You can see three rectangles. Green, red and white.

 

For each of these rectangles, the corresponding widget ids can be seen on the left.

 

The top most id is the parent id, below that is the child id.

 

For some widgets there may be three ids, the third is just a child of the second id.

 

In this case we want to get the widget for the green rectangle, so in code this would be:

RS2Widget skillTab = getWidgets().get(548, 53); 

When accessing widgets, if a widget is not on screen it will be null, so always make sure to null check your widgets. 

 

You can now interact with this widget for example:

private void openSkillTab(){
  RS2Widget skillTab = getWidgets().get(548, 53); 
  if(skillTab != null) skillTab.interact();
} 

If you are ever trying to interact with a widget that has text in it, just find the widget using the text, this is a more reliable solution, for example:

RS2Widget troutWidget = getWidgets().getWidgetContainingText("Raw trout");
Edited by Explv
  • Like 2
  • Heart 1
Link to comment
Share on other sites

http://osbot.org/api/org/osbot/rs07/api/ui/RS2Widget.html

http://osbot.org/api/org/osbot/rs07/api/Widgets.html

 

public class Widgets
extends FilterAPI<RS2Widget>

Represents the API regarding widget (previously called interfaces) functionality.
 
Lets start by creating our variable.
 
Well call the RS2Widget
RS2Widget interface1;

initiate the variable and we grab widgets like this

interface1 = getWidgets().get(PARENT_ID, CHILD_ID);

To find out how to get the PARENT_ID, CHILD_ID

we go here

R7pyRRK.gif

 

We then want to select a interface

I chose the inventory

8xMcVQu.gif

 

interface debugger follows a color scheme find the interface you would like with the matching colour.

R = 548 is our widget parent id

- = 55 is our widget child id

 

we then can finish

interface1 = getWidgets().get(548, 55);

we then can interact with the widget

interface1 = getWidgets().get(548, 55);

if (interface1 != null) interface1.interact("action");

fuk u explv u beat me to it

Edited by TFW
  • Like 2
  • Heart 1
Link to comment
Share on other sites

 

Step 1) Go to settings -> options -> debug -> tick Widgets

 

3dd602bb43.png

 

Step 2) Hover your mouse over the part of the screen you want to be able to interact with using widgets

 

KIqzlZy.png

 

 

In this case, the mouse is hovering over the skills tab. You can see three rectangles. Green, red and white.

 

For each of these rectangles, the corresponding widget ids can be seen on the left.

 

The top most id is the parent id, below that is the child id.

 

For some widgets there may be three ids, the third is just a child of the second id.

 

In this case we want to get the widget for the green rectangle, so in code this would be:

RS2Widget skillTab = getWidgets().get(548, 53); 

When accessing widgets, if a widget is not on screen it will be null, so always make sure to null check your widgets. 

 

You can now interact with this widget for example:

private void openSkillTab(){
  RS2Widget skillTab = getWidgets().get(548, 53); 
  if(skillTab != null) skillTab.interact();
} 

If you are ever trying to interact with a widget that has text in it, just find the widget using the text, this is a more reliable solution, for example:

RS2Widget troutWidget = getWidgets().getWidgetContainingText("Raw trout");

 

Explv back at it again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...