Step 1) Go to settings -> options -> debug -> tick Widgets
Step 2) Hover your mouse over the part of the screen you want to be able to interact with using widgets
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");