Jump to content

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


vlad3921

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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;
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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