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
  • Try asking for help in the chatbox
  • Cancel selection of item


    KankerHenk
     Share

    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()

     

    Edited by SubCZ
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.