Jump to content

How To Change Your Script Mouse Cursor


Swizzbeat

Recommended Posts

Finally figured out how to do this and I figured others might want to as well, so here's the code!

 

Put this in your global variable declaration:

public Image cursor;

Have this in your onStart() method:

useDefaultPaint(false);
		
try {
    cursor = ImageIO.read(new URL("YOUR IMAGE URL GOES HERE"));
}
catch (MalformedURLException e) {
    log("Error in retrieving mouse cursor!");
}
catch (IOException e) {
    log("Error in retrieving mouse cursor!");
}

And then finally put this somewhere in your onPaint() method:

int mX = client.getMousePosition().x;
int mY = client.getMousePosition().y;

g.drawImage(cursor, mX, mY, null);

FYI if you use the method moveMouseOutsideScreen() the mouse image you use will appear in the top left of the screen. This is completely normal however it may look a little weird! If you would rather just not have it drawn at all you can do this:

if (mX == -1) {
    //don't draw
}
else {
    //draw
}
Edited by Swizzbeat
  • Like 3
Link to comment
Share on other sites

  • 2 months later...

 

int mX = client.getMousePosition().x;
int mY = client.getMousePosition().y;
 
Do both those not just return -1 if the mouse is outside the screen?

 

Yes, so if the mouse is currently outside of the screen the cursor will appear at the top left of the game window (however it is still technically outside).

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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