Java internal mouse?

Discussion in 'Programming General' started by Arravs flow, Jan 17, 2012.

Java internal mouse?
  1. Unread #1 - Jan 17, 2012 at 12:34 AM
  2. Arravs flow
    Joined:
    Jan 17, 2012
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    Arravs flow Newcomer

    Java internal mouse?

    Ok so i created this bot which auto alchs for me and logs out.
    I'm really frustrated on how to make it use a 2nd mouse say to speak.
    I've heard you can use reflection if you use the correct loaders but i'm not too familiar with reflection so...ye

    Here is the code help will be appreciated :)

    Code:
    package com.xero.macros;
    
    import java.awt.AWTException;
    
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.MouseInfo;
    import java.awt.Point;
    import java.awt.PointerInfo;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.InputEvent;
    import java.awt.event.MouseEvent;
    import java.io.IOException;
    import java.net.URL;
    
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import javax.swing.ImageIcon;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.UIManager;
    
    import com.xero.Logger;
    /**
     * 
     * @author Tyler(Arravs flow , skrillex etc on diff forums)
     *
     */
    public class Alcher extends JFrame {
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = -8286155230324582877L;
    	public static int alchs = 0;
    	Graphics g1;
    	public int alchTo = 100;
    	private JPanel contentPane;
    	private JTextField textField;
    	public static Dimension size;
    	Robot robot = new Robot();
    	public boolean mageTab = false;
    	/**
    	 * Launch the application.
    	 */
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			
    			public void run() {
    				try {
    					
    					
    					UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    					Alcher frame = new Alcher();
    					frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    	}
    	/**
    	 * Create the frame.
    	 * @throws AWTException 
    	 * @throws IOException 
    	 */
    	public Alcher() throws AWTException, IOException {
    		setResizable(false);
    		size = Toolkit.getDefaultToolkit().getScreenSize();
    		setTitle("Alcher Pro");
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setBounds(100, 100, 174, 140);
    		contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		setContentPane(contentPane);
    		contentPane.setLayout(null);
    		setLocation(
            (int)(size.getWidth()-contentPane.getWidth())/2,
            (int)(size.getHeight()-contentPane.getHeight())/2);
    		JLabel lblEnterAmount = new JLabel("Enter Amount:");
    		lblEnterAmount.setBounds(44, 11, 83, 27);
    		contentPane.add(lblEnterAmount);
    		textField = new JTextField();
    		textField.setBounds(0, 32, 166, 27);
    		contentPane.add(textField);
    		textField.setColumns(10);
    		JButton btnStartAlching = new JButton("Start Alching");
    		btnStartAlching.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				 Logger.log("Alcher Pro", "Alching Pro Started!");
    				 try {
    					click();
    				} catch (InterruptedException e1) {
    					e1.printStackTrace();
    				}
    			}
    		});
    		btnStartAlching.setBounds(0, 83, 166, 23);
    		contentPane.add(btnStartAlching);
    		
    		JLabel lblRedemptionBotting = new JLabel("Redemption Botting");
    		lblRedemptionBotting.setBounds(30, 70, 136, 14);
    		contentPane.add(lblRedemptionBotting);
    	}
    	public void click() throws InterruptedException {
    		int many = Integer.parseInt(textField.getText());
    		if(alchs == many) {
    			ranOutOfAlchs();
    			Logger.log("Alcher Pro","---------------------");
    			Logger.log("Alcher", "Completed Alching, logging out!");
    			Logger.log("Alcher Pro","---------------------");
    			Thread.sleep(2000);
    			System.exit(0);
    		}
    		for (int i = 0; i < many; i++) {
    			try {
    				robot.mousePress(MouseEvent.BUTTON1_MASK);
    				robot.mouseRelease(InputEvent.BUTTON1_MASK);
    				robot.mousePress(InputEvent.BUTTON1_MASK);
    				robot.mouseRelease(InputEvent.BUTTON1_MASK);
    				robot.mouseMove(866,400);
    				Thread.sleep(4000);
    				alchs++;
    				Logger.log("Alcher Pro", "Alch number: "+alchs);
    			} catch (InterruptedException e) {
    				e.printStackTrace();
    				System.exit(0);
    			}
    		}
    	}
    	
    	public void SmoothMove(Point Destination, double Speed){
    		//Credits to Flaming Idiots for this as well, it was only converted to Java by SlashShot
       		try {
    	   		Robot robot = new Robot();
    	   		PointerInfo PInfo = MouseInfo.getPointerInfo();
    			Point origin = PInfo.getLocation();
    	   		Point Difference = new Point((int)(Destination.getX() - PInfo.getLocation().getX()),(int)(Destination.getY() - PInfo.getLocation().getY()));	
    
    			
    			for(double Current = 0; Current < 1; Current+= (Speed/Math.sqrt(Math.pow(Difference.getX(),2) + Math.pow(Difference.getY(),2)))){
    				PInfo = MouseInfo.getPointerInfo();
    				robot.mouseMove((int)origin.getX() + (int)(Difference.getX() * Current),(int)origin.getY() + (int)(Difference.getY() * Current));
    				robot.setAutoDelay(3);
    			}
    		}catch(java.awt.AWTException exc) {
    			System.out.println("error");
    		}
    	}
        public Point FindPixelByColor(Rectangle Window, Color Colour)
        {
            try
            {
                Robot Robot = new Robot();
                for(int x = Window.x; x < Window.width; x++)
                    for(int y = Window.y; y < Window.height; y++)
                        if(Robot.getPixelColor(x, y).getRGB() == Colour.getRGB())
                            return new Point(x, y);
            }
            catch(Exception Exception)
            {
                Exception.printStackTrace();
            }
            return null;
        }
    
    	public void ranOutOfAlchs() throws InterruptedException {
    		robot.mouseMove(1060,35);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
    		robot.mouseRelease(InputEvent.BUTTON1_MASK);
    		Thread.sleep(1500);
    		robot.mouseMove(900,380);
    		Thread.sleep(1500);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
    		robot.mouseRelease(InputEvent.BUTTON1_MASK);
    	}
    }
    
     
  3. Unread #2 - Jan 17, 2012 at 1:02 AM
  4. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Java internal mouse?

    Using more than one mouse is not simple because then you have to actually load the applet into your program and perform all the mouse actions through Java itself and this means the mouse only interacts with the Java frame not the rest of your screen.

    The robot class mouse actions you are using actually get transformed to operating system specific mouse input calls and that's why they take effect outside of the Java application as well.

    If you just want to alch with a second bot at the same time then just modify your program slightly to alternate between alching for multiple windows. i.e. clicking on the first, then the second, then the first, and so on.

    Also, letting yourself specify the coordinates on startup somehow would help too because you could just put in 2 sets for it to alternate between. (one set for each character logged in)
     
  5. Unread #3 - Jan 17, 2012 at 8:34 AM
  6. The Black Tux
    Joined:
    Apr 19, 2009
    Posts:
    10,306
    Referrals:
    30
    Sythe Gold:
    55
    Vouch Thread:
    Click Here
    Two Factor Authentication User Cool Kid Former OMM Cook RsProd Sythe Awards 2012 Winner Village Drunk

    The Black Tux Veteran
    The Black Tux Donor Java Programmers PHP Programmers

    Java internal mouse?

    This is for RS botting?

    I suggest either using an source of a client and add your clicker (Still needs lots of modification) or a current bot like JBot
     
  7. Unread #4 - Jan 17, 2012 at 9:54 AM
  8. Arravs flow
    Joined:
    Jan 17, 2012
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    Arravs flow Newcomer

    Java internal mouse?

    Well if i used that there would have to be a lot of modification since the cluster fluter bs caused a lot of changes in the code.

    Also i have a loader just i'll have to load the applet in in like he said. :\
     
< [TUT] Making your own interpreted scripting language | GrandExchange Grabber >

Users viewing this thread
1 guest


 
 
Adblock breaks this site