Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • can someone help me make a mouse listener (click time, position)?


    darkjack7
     Share

    Recommended Posts

    import java.awt.Graphics2D;
    import java.awt.GridLayout;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Timer;
    
    
    @ScriptManifest(name = "GOBLINS", description = "", author = "", version = 0, category = Category.COMBAT)
    public abstract class main extends AbstractScript implements MouseListener {    
    
    	 Timer t;
    	 
    	 int xpos; 
    	 int ypos;
    	 
    	 Rectangle screen = new Rectangle();
    	 
    	  
    
    
    	void eventOutput(String eventDescription, MouseEvent e) {
            log(eventDescription + " detected on "
                    + e.getComponent().getClass().getName()
                    + "." + String.valueOf(xpos));
        }
         
        public void mousePressed(MouseEvent e) {
            eventOutput("Mouse pressed (# of clicks: "
                    + e.getClickCount() + ")", e);
        }
         
        public void mouseReleased(MouseEvent e) {
            eventOutput("Mouse released (# of clicks: "
                    + e.getClickCount() + ")", e);
        }
         
        public void mouseEntered(MouseEvent e) {
            eventOutput("Mouse entered", e);
        }
         
        public void mouseExited(MouseEvent e) {
            eventOutput("Mouse exited", e);
        }
         
        public void mouseClicked(MouseEvent e) {
            eventOutput("Mouse clicked (# of clicks: "
                    + e.getClickCount() + ")", e);
        }
    	
    	public void onPaint(Graphics2D g) {
    		}
    	}
    

    this is what i have so far but db doesn't even recognize it :doge: help pls i really want to do this

    Link to comment
    Share on other sites

    As I said in the chatbox not sure if you've seen, I've implemented the interface on a class of my own and it works just fine.

     

    Btw, I don't think you want your main to be abstract.

                                                                       ^ this is the problem. Implement onLoop() and should be just fine.

     

    Hf.

    Edited by TheBibleKills
    Link to comment
    Share on other sites

    ^ If your class is abstract, then the script cant be run. Bible is right.

    The class NEEDS to be abstract to be able to run in the DB client lol. You just need to implement the onLoop(), because thats basically your "public static void main(String[] args)" method. A Java program will look for the main method on startup, this is the way Java works, and executes the code in the body. DreamBot does this by the onLoop().

     

    Could be that im wrong, but thats what i think how dreambot works :P

     

    oh and, @darkjack7, a Java Class starts with an uppercase letter. always. So change "main" to "Main"

    And remove the abstract callsign, you implement AbstractScript which is abstract lol. (see below)

    public class Main extends AbstractScript implements MouseListener {
    
    Edited by Cardozz
    Link to comment
    Share on other sites

    No the class cannot be abstract. AbstractScript is abstract which is why you have to implement methods. But the class that is running cannot be abstract

     

    But he is correct. Because you extend AbstractScript you do need an onLoop even if it does nothing.

    Edited by Hopewelljnj
    Link to comment
    Share on other sites

    No the class cannot be abstract. AbstractScript is abstract which is why you have to implement methods. But the class that is running cannot be abstract

     

    But he is correct. Because you extend AbstractScript you do need an onLoop even if it does nothing.

    Thats what i tried to say lol. Thanks for the support :)

    Link to comment
    Share on other sites

    Yeah, I think we are all on the same page here. We figured this out a little later in the chat by implementing onLoop().

    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.