Aluf

Java spam bot 2

Jan 20th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. package main;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6.  
  7. @SuppressWarnings("serial")
  8. public class Main extends JFrame {
  9.  
  10. static Main gui = new Main();
  11.  
  12. private JLabel label;
  13. private JButton startButton, stopButton;
  14. private JTextField textField;
  15.  
  16. private Timer timer;
  17.  
  18. public static void main(String args[]){
  19. gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20. gui.setSize(270, 90);
  21. gui.setVisible(true);
  22. gui.setResizable(false);
  23. gui.setLocationRelativeTo(null);
  24. gui.setTitle("SpamBot | By Klintos");
  25. }
  26.  
  27. public class eventStart implements ActionListener {
  28. public void actionPerformed(ActionEvent startEvent) {
  29. gui.setTitle("Currently Spamming");
  30. timer.start();
  31. }
  32. }
  33.  
  34. public class eventStop implements ActionListener {
  35. public void actionPerformed(ActionEvent stopEvent) {
  36. gui.setTitle("Not Spamming");
  37. timer.stop();
  38. }
  39. }
  40.  
  41. public Main(){
  42. setLayout(new FlowLayout());
  43. addObjects();
  44.  
  45. timer = new Timer(25, spamBot);
  46.  
  47. eventStart startEvent = new eventStart();
  48. startButton.addActionListener(startEvent);
  49. eventStop stopEvent = new eventStop();
  50. stopButton.addActionListener(stopEvent);
  51. }
  52.  
  53. private void addObjects(){
  54. label = new JLabel("Spam Text: ");
  55. textField = new JTextField(16);
  56. startButton = new JButton("Start Spamming");
  57. stopButton = new JButton("Stop Spamming");
  58. add(label);
  59. add(textField);
  60. add(startButton);
  61. add(stopButton);
  62. }
  63.  
  64. ActionListener spamBot = new ActionListener() {
  65. public void actionPerformed(ActionEvent event) {
  66. try {
  67. Robot robot = new Robot();
  68.  
  69. for(char c : textField.getText().toCharArray()){
  70. int key = KeyEvent.getExtendedKeyCodeForChar(c);
  71.  
  72. robot.keyPress(key);
  73. robot.keyRelease(key);
  74. }
  75. robot.keyPress(KeyEvent.VK_ENTER);
  76. robot.keyRelease(KeyEvent.VK_ENTER);
  77. } catch (AWTException e) {
  78. e.printStackTrace();
  79. }
  80. }
  81. };
  82. }
Advertisement
Add Comment
Please, Sign In to add comment