Jump to content

Is there any way to customize some built-in timers?


Recommended Posts

Posted

As an example, npc.interact("Talk") does the following::

1. Moves mouse to npc

2. Right clicks on npc

3. Moves mouse to 'Talk' option

4. Left clicks on it

Steps 2 to 4  are done in extremely fast succession so I'd like to add in a little delay in between those steps to help with antiban. The same goes for other built in api methods, such as bank.depositAll() or store.buy(). Is this possible? If yes, how would you do it?

 

Side question: How would you simulate a random mouse movement on screen? Currently, the pointer moves only if osbot was given a command which is fine, but I'd like to add some random, natural mouse movement while there is no command(event) being run.

Posted (edited)

Thanks, that's what I thought. What's the API that deals with the menu that opens up when you right click on an object such as npc or chest?

 

I managed to get as far as right clicking on my object, but now I'm not sure how to choose the option I want from the popup.

Edited by vlad3921
Posted

This will right click an entity and click the action. You can add sleeps wherever you would like. You can also add offsets to the mouse position so that it is more randomized.

private boolean customRightClickInteract(Entity entity, String interaction) throws InterruptedException {
    if (entity != null && entity.hover()) {
        // Right clicks the entity.
        getMouse().click(true);
        // This creates a temporary actionOption to later hold the actual option.
        Option actionOption = null;
        // This loops through all the active options on the screen and checks to see if
        // any match the interaction string.
        // It also increases the index so that it can later be used to grab the correct
        // rectangle from the option.
        int index = 0;
        for (Option option : getMenuAPI().getMenu()) {
            if (option.action.toLowerCase().equalsIgnoreCase(interaction.toLowerCase())) {
                actionOption = option;
                break;
            }
            index++;
        }
        if (actionOption != null) {
            // Moves the mouse to the designated action. You should probably give offsets
            // to the rec.getCenterX() and the rec.getCenterY() so that it doesn't always
            // go to the center of the text. The y will only be able to have an offset
            // of around -3 - 3 or so.
            // The x should be able to handle more maybe -15 - 15? You will have to
            // mess around with it.
            Rectangle rec = getMenuAPI().getOptionRectangle(index);
            getMouse().move((int) rec.getCenterX(), (int) rec.getCenterY());
            return getMouse().click(false);
        }
    }
    return false;
}

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
  • Recently Browsing   0 members

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