Jump to content

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


colby__

Recommended Posts

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

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

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

 

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