Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Cancel selection of item


    KankerHenk

    Recommended Posts

    Hey, I'm having some trouble where a script will sometimes have an item selected after dropping an inventory, and then fails to perform its next action. The solution is to click somewhere to de-select the item. The only way i've found that seems to work is to move the mouse to a random position and click(). I was wondering if there is a more elegant way of canceling a selection.

    The way i currently do it is as follows:

    if(mc.getInventory().getSelectedItemIndex() != -1){
                Point p = new Point(Calculations.random(520, 549), Calculations.random(208, 338));
                mc.getMouse().move(p);
                sleep(randomWait(1400));
                mc.getMouse().click();
                sleep(randomWait(1800));
            }

    (mc here is the method context or 'this' of the script)

     

    Thanks!

    Link to comment
    Share on other sites

    The Inventory class has a built in method for this:

    mc.getInventory().deselect()

     

    Note that Inventory also has a method to check if an item is selected:

    mc.getInventory().isItemSelected()

     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.