Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package core.ui;
- import java.awt.EventQueue;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JCheckBoxMenuItem;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JPanel;
- import javax.swing.JSpinner;
- import javax.swing.SpinnerNumberModel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import org.jvnet.substance.SubstanceLookAndFeel;
- import org.jvnet.substance.api.skin.GraphiteAquaSkin;
- import core.mouse.Mouse;
- import javax.swing.ImageIcon;
- import java.awt.Font;
- public class Gui extends JFrame {
- /*
- *Written By TheScrub
- *Under copyleft licensing.
- */
- private JPanel contentPane;
- private Mouse mouse = new Mouse();
- private boolean useDelay = true;
- private boolean clickMouse = false;
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- SubstanceLookAndFeel.setSkin(new GraphiteAquaSkin());
- Gui frame = new Gui();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Gui() {
- setTitle("Scrub Auto Clicker");
- setAlwaysOnTop(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 207, 122);
- JMenuBar menuBar = new JMenuBar();
- setJMenuBar(menuBar);
- JMenu mnFile = new JMenu("File");
- mnFile.setFont(new Font("Calibri", Font.BOLD, 16));
- mnFile.setIcon(new ImageIcon(Gui.class.getResource("/resource/application_view_detail.png")));
- menuBar.add(mnFile);
- JMenuItem mntmAbout = new JMenuItem("About");
- mntmAbout.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- Information.main(null);
- }
- });
- final JCheckBoxMenuItem chckbxmntmUseDelay = new JCheckBoxMenuItem(
- "Use Delay");
- chckbxmntmUseDelay.setSelected(true);
- mnFile.add(chckbxmntmUseDelay);
- mnFile.add(mntmAbout);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- final JLabel lblDelay = new JLabel("Delay: \r\n" + "1000 M/S");
- lblDelay.setBounds(10, 11, 108, 14);
- contentPane.add(lblDelay);
- final JButton btnStart = new JButton("Start");
- btnStart.setBounds(49, 36, 91, 23);
- contentPane.add(btnStart);
- final JSpinner delaySpinner = new JSpinner();
- delaySpinner.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent arg0) {
- lblDelay.setText("Delay: \r\n" + delaySpinner.getValue()
- + " M/S");
- }
- });
- delaySpinner.setModel(new SpinnerNumberModel(1000, 1, 10000, 100));
- delaySpinner.setBounds(128, 9, 61, 18);
- contentPane.add(delaySpinner);
- btnStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- clickMouse = !clickMouse ? true : false;
- System.out.println("Mouse clicking: " + clickMouse);
- mouse.setDelayTime((int) delaySpinner.getValue());
- mouse.setDelayUse(useDelay);
- mouse.setRunning(clickMouse);
- btnStart.setText(clickMouse ? "Stop" : "Start");
- if (clickMouse) {
- // creating new instance so we can call start more than once
- new Thread(mouse).start();
- }
- }
- });
- chckbxmntmUseDelay.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- useDelay = chckbxmntmUseDelay.isSelected() ? true : false;
- delaySpinner.setEnabled(useDelay);
- }
- });
- }
- }
- package core.mouse;
- import java.awt.AWTException;
- import java.awt.MouseInfo;
- import java.awt.Point;
- import java.awt.Robot;
- import java.awt.event.InputEvent;
- public class Mouse extends Thread{
- private Robot robot;
- private int delayTime;
- private boolean useDelay;
- private boolean running = false;
- public Mouse() {
- try {
- robot = new Robot();
- } catch (AWTException e) {
- System.out.println("Failed to load robot");
- e.printStackTrace();
- }
- }
- public Point getLocation() {
- return MouseInfo.getPointerInfo().getLocation();
- }
- public String getLocationString() {
- Point p = getLocation();
- return p.x + "," + p.y;
- }
- public void setDelayTime(int delayTime) {
- this.delayTime = delayTime;
- }
- public void setDelayUse(boolean useDelay) {
- this.useDelay = useDelay;
- }
- public void setRunning(boolean running) {
- this.running = running;
- }
- public boolean isRunning() {
- return running;
- }
- public void leftClickMouse() {
- if (useDelay)
- robot.delay(delayTime);
- robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_MASK);
- }
- @Override
- public void run(){
- while (isRunning()) {
- leftClickMouse();
- }
- }
- }
- package core.ui;
- import java.awt.BorderLayout;
- public class Information extends JFrame {
- private JPanel contentPane;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Information frame = new Information();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Information() {
- setTitle("Information");
- setAlwaysOnTop(true);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setBounds(100, 100, 301, 167);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- JEditorPane dtrpnThisAutoClicker = new JEditorPane();
- dtrpnThisAutoClicker.setText("This auto clicker is for learning resources only \r\nyou can find a link to the source in here soon");
- dtrpnThisAutoClicker.setEditable(false);
- dtrpnThisAutoClicker.setBounds(10, 11, 273, 118);
- contentPane.add(dtrpnThisAutoClicker);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement