Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class Main extends JFrame {
- static Main gui = new Main();
- private JLabel label;
- private JButton startButton, stopButton;
- private JTextField textField;
- private Timer timer;
- public static void main(String args[]){
- gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- gui.setSize(270, 90);
- gui.setVisible(true);
- gui.setResizable(false);
- gui.setLocationRelativeTo(null);
- gui.setTitle("SpamBot | By Klintos");
- }
- public class eventStart implements ActionListener {
- public void actionPerformed(ActionEvent startEvent) {
- gui.setTitle("Currently Spamming");
- timer.start();
- }
- }
- public class eventStop implements ActionListener {
- public void actionPerformed(ActionEvent stopEvent) {
- gui.setTitle("Not Spamming");
- timer.stop();
- }
- }
- public Main(){
- setLayout(new FlowLayout());
- addObjects();
- timer = new Timer(25, spamBot);
- eventStart startEvent = new eventStart();
- startButton.addActionListener(startEvent);
- eventStop stopEvent = new eventStop();
- stopButton.addActionListener(stopEvent);
- }
- private void addObjects(){
- label = new JLabel("Spam Text: ");
- textField = new JTextField(16);
- startButton = new JButton("Start Spamming");
- stopButton = new JButton("Stop Spamming");
- add(label);
- add(textField);
- add(startButton);
- add(stopButton);
- }
- ActionListener spamBot = new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- try {
- Robot robot = new Robot();
- for(char c : textField.getText().toCharArray()){
- int key = KeyEvent.getExtendedKeyCodeForChar(c);
- robot.keyPress(key);
- robot.keyRelease(key);
- }
- robot.keyPress(KeyEvent.VK_ENTER);
- robot.keyRelease(KeyEvent.VK_ENTER);
- } catch (AWTException e) {
- e.printStackTrace();
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment