Jump to content

java.security.AccessControlException: access denied ("java.awt.AWTPermission" "createRobot")


Recommended Posts

Posted (edited)

MouseClicked is all you need really AFAIK. It will fire the event directly yes.

EDIT: scratch that, I believe the proper procedure is:

MousePressed

MouseReleased

MouseClicked

In that order

 

botInput indicates whether this mouse event was generated by the bot, or by the user

popuptrigger indicates whether or not this event triggers a popup (it does not)

time is the timestamp for which this event occured (now)

 

From AWT MouseEvent:

0c94e04ac6f7096a5e42182060f5534a.png

What would be a popup trigger? When would it be true? Also do you know which component I should pass?

Edited by colby__
Posted (edited)

Here is the code I have so far:

 

    public void click(int x, int y, int xT, int yT, boolean button) {
        x = mX = dev(x, xT);
        y = mY = dev(y, yT);

        int b0 = button ? MouseEvent.BUTTON1 : MouseEvent.BUTTON2;
        long t0 = System.currentTimeMillis(), t1 = t0;
        t0 -= dev(1, 80F);

        Component c = bot.getCanvas();

        MouseEvent evt = new MouseEvent(c, MouseEvent.MOUSE_MOVED, t0, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseMoved(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, t0, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mousePressed(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_RELEASED, t1, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseReleased(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_CLICKED, t1, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseClicked(evt);
    }

I am painting mX and mY and it's definitely on the game screen yet it is not registering as a click, not walking or even showing hover options when the mouse event is fired over an object. Any ideas?

EDIT: The code DOES work but only when human input is ENABLED in the gui. Upon disabling human input, the code no longer clicks. How can I bypass this?

Edited by colby__
Posted

Here is the code I have so far:

 

    public void click(int x, int y, int xT, int yT, boolean button) {
        x = mX = dev(x, xT);
        y = mY = dev(y, yT);

        int b0 = button ? MouseEvent.BUTTON1 : MouseEvent.BUTTON2;
        long t0 = System.currentTimeMillis(), t1 = t0;
        t0 -= dev(1, 80F);

        Component c = bot.getCanvas();

        MouseEvent evt = new MouseEvent(c, MouseEvent.MOUSE_MOVED, t0, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseMoved(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, t0, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mousePressed(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_RELEASED, t1, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseReleased(evt);
        evt = new MouseEvent(c, MouseEvent.MOUSE_CLICKED, t1, 0, x, y, 1, false, b0);
        bot.getMouseEventHandler().mouseClicked(evt);
    }

I am painting mX and mY and it's definitely on the game screen yet it is not registering as a click, not walking or even showing hover options when the mouse event is fired over an object. Any ideas?

EDIT: The code DOES work but only when human input is ENABLED in the gui. Upon disabling human input, the code no longer clicks. How can I bypass this?

 

Incase any1 else wonder;

It can be 'fixed' by setting botInput to true

 

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