saintpaul1 Posted April 22, 2023 Share Posted April 22, 2023 (edited) Trying to click "Deposit loot" in the looting bag. I have tried the following combinations: RS2Widget depositLootButton = getWidgets().get(15, 8); RS2Widget depositLootButton = getWidgets().get(15, 9); RS2Widget depositLootButton = getWidgets().get(548, 77); RS2Widget depositLootButton = getWidgets().getWidgetContainingAction("Deposit loot"); depositLootButton.interact("Deposit loot"); depositLootButton.interact(); What am i doing wrong? first time using widgets. i assume the widget code is 15,8 because the text is green and the widget i want to click is highlighted in green, but i have tried all other combinations aswell. EDIT: i managed to get it to click it using RS2Widget depositLootButton = getWidgets().getWidgetContainingAction("Deposit loot"); RS2Widget depositLootButton = getWidgets().getWidgetContainingAction("Deposit loot"); But only if i didnt check if it was null first, and it threw a null exception error but it still clicked it. So i dont know what to do, if i only click it if its not null it wont click it. Edited April 22, 2023 by saintpaul1 Quote Link to comment Share on other sites More sharing options...
Gunman Posted April 22, 2023 Share Posted April 22, 2023 @saintpaul1 Run this and see what gets logged final RS2Widget widget = getWidgets().getAll().stream() .filter(w -> w.hasAction("Deposit loot")) .findFirst() .orElse(null); if (widget != null) { log("RootId: " + widget.getRootId()); log("ChildId: " + widget.getSecondLevelId()); log("GrandChildId: " + widget.getThirdLevelId()); } else { log("Widget couldn't be found!"); } Quote Link to comment Share on other sites More sharing options...
saintpaul1 Posted April 22, 2023 Author Share Posted April 22, 2023 (edited) 31 minutes ago, Gunman said: @saintpaul1 Run this and see what gets logged final RS2Widget widget = getWidgets().getAll().stream() .filter(w -> w.hasAction("Deposit loot")) .findFirst() .orElse(null); if (widget != null) { log("RootId: " + widget.getRootId()); log("ChildId: " + widget.getSecondLevelId()); log("GrandChildId: " + widget.getThirdLevelId()); } else { log("Widget couldn't be found!"); } Thanks gunman, this is what it logs : [INFO][Bot #1][04/22 11:00:45 PM]: RootId: 15 [INFO][Bot #1][04/22 11:00:45 PM]: ChildId: 8 [INFO][Bot #1][04/22 11:00:45 PM]: GrandChildId: -1 So i guess i should include -1? Also i got it to run by using .isvisible instead of nullchecking, i got a null exception error but it ran still, but id rather do it properly. This is my code now : RS2Widget depositLootingBag = getWidgets().get(15, 2, 0); RS2Widget bagEmpty = getWidgets().getWidgetContainingText("The bag is empty."); RS2Widget depositLootButton = getWidgets().get(15, 8 , -1); RS2Widget dismiss = getWidgets().getWidgetContainingAction("Dismiss"); if (getBank().isOpen()) { Item lootingBag = getInventory().getItem("Looting bag"); if (depositLootingBag != null) { log("Lets deposit looting bag items."); lootingBag.interact("View"); Util.Sleep.sleepUntil(() -> depositLootButton !=null, 10000); if (depositLootButton !=null) { log("Item in bag to deposit."); depositLootButton.interact("Deposit loot"); Util.Sleep.sleepUntil(() -> bagEmpty !=null, 5000); if (bagEmpty !=null) { log("Clicking dismiss."); dismiss.interact("Dismiss"); } } return 100; } } Edited April 22, 2023 by saintpaul1 Quote Link to comment Share on other sites More sharing options...
Gunman Posted April 22, 2023 Share Posted April 22, 2023 4 minutes ago, saintpaul1 said: So i guess i should include -1? Also i got it to run by using .isvisible instead of nullchecking, i got a null exception error but it ran still, but id rather do it properly. -1 should mean it's not a grand child so no. I don't get how it would run if the widget is null, you can't call a method on something that doesn't exist. My guess is the null was from the .isVisible check if you interacted with the widget. Quote Link to comment Share on other sites More sharing options...
saintpaul1 Posted April 23, 2023 Author Share Posted April 23, 2023 13 hours ago, Gunman said: -1 should mean it's not a grand child so no. I don't get how it would run if the widget is null, you can't call a method on something that doesn't exist. My guess is the null was from the .isVisible check if you interacted with the widget. Ah okay yeah your right. i got it working now perfect, heres the code if anyone needs : if (getBank().isOpen()) { RS2Widget depositLootingBag = getWidgets().getWidgetContainingAction("View"); RS2Widget bagEmpty = getWidgets().getWidgetContainingText("The bag is empty."); RS2Widget depositLootButton = getWidgets().getWidgetContainingAction("Deposit loot"); RS2Widget dismiss = getWidgets().getWidgetContainingAction("Dismiss"); if (depositLootingBag != null) { log("Deposit looting bag is not null"); depositLootingBag.interact(); } if (depositLootingBag == null) { log("Deposit looting bag is null"); } if (depositLootButton !=null && bagEmpty ==null) { log("Pressing deposit loot button"); depositLootButton.interact("Deposit loot"); } if (bagEmpty !=null) { log("Bag empty message onscreen"); dismiss.interact(); } Quote Link to comment Share on other sites More sharing options...