Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1.  
  2. import java.awt.AWTException;
  3. import java.awt.Color;
  4. import java.awt.MouseInfo;
  5. import java.awt.Robot;
  6. import java.awt.event.InputEvent;
  7. import java.awt.event.KeyEvent;
  8. import java.util.Properties;
  9. import java.util.concurrent.TimeUnit;
  10.  
  11. import javax.mail.Message;
  12. import javax.mail.MessagingException;
  13. import javax.mail.PasswordAuthentication;
  14. import javax.mail.Session;
  15. import javax.mail.Transport;
  16. import javax.mail.internet.AddressException;
  17. import javax.mail.internet.InternetAddress;
  18. import javax.mail.internet.MimeMessage;
  19. import javax.sound.sampled.AudioInputStream;
  20. import javax.sound.sampled.AudioSystem;
  21. import javax.sound.sampled.Clip;
  22.  
  23. public class Bot {
  24.  
  25. public static final int TICKET_X = 930; //1163
  26. public static final int TICKET_Y = 600; //750
  27.  
  28. public static final int BUTTON1_X = 1200;
  29. public static final int BUTTON1_Y = 600;
  30.  
  31. public static final int BUTTON2_X = 1200;
  32. public static final int BUTTON2_Y = 520;
  33.  
  34. public int listing_color_white = new Color(255,255,255).getRGB();
  35. public int button_color_green = new Color(26, 210, 108).getRGB();
  36. public int button_color_green_hover = new Color(51, 216, 125).getRGB();
  37.  
  38.  
  39. public void Move() throws InterruptedException, AWTException {
  40. Robot bot = new Robot();
  41. TimeUnit.MILLISECONDS.sleep(3000);
  42.  
  43. // check for tickets
  44. bot.mouseMove(0, 0);
  45. bot.mouseMove(TICKET_X, TICKET_Y); // move to ticket
  46.  
  47. while (bot.getPixelColor(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y)
  48. .getRGB() == listing_color_white ) {
  49.  
  50. bot.keyPress(KeyEvent.VK_F5);
  51. bot.keyRelease(KeyEvent.VK_F5);
  52. TimeUnit.MILLISECONDS.sleep(2000);
  53.  
  54. if (bot.getPixelColor(MouseInfo.getPointerInfo().getLocation().x,
  55. MouseInfo.getPointerInfo().getLocation().y).getRGB() != listing_color_white) {
  56. break;
  57. }
  58. }
  59.  
  60. bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  61. bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  62.  
  63. PlaySound();
  64.  
  65. bot.mouseMove(BUTTON1_X, BUTTON1_Y); // move to buy button 1
  66.  
  67. while (bot.getPixelColor(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y).getRGB() != button_color_green) {
  68. TimeUnit.MILLISECONDS.sleep(100);
  69. }
  70.  
  71. bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  72. bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  73.  
  74. bot.mouseMove(BUTTON2_X, BUTTON2_Y); // move to buy button 2
  75.  
  76. SendEmail();
  77.  
  78. while (bot.getPixelColor(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y)
  79. .getRGB() != button_color_green_hover) {
  80. TimeUnit.MILLISECONDS.sleep(500);
  81. }
  82.  
  83. bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  84. bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  85.  
  86. TimeUnit.MILLISECONDS.sleep(240000);
  87.  
  88. }
  89.  
  90. public void PlaySound() {
  91. try {
  92. AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("toppertje.wav"));
  93. Clip clip = AudioSystem.getClip();
  94. clip.open(audioInputStream);
  95. clip.start();
  96. // If you want the sound to loop infinitely, then put: clip.loop(Clip.LOOP_CONTINUOUSLY);
  97. // If you want to stop the sound, then use clip.stop();
  98. } catch (Exception ex) {
  99. ex.printStackTrace();
  100. }
  101. }
  102.  
  103. public void SendEmail() {
  104. final String username = "luukpook@gmail.com";
  105. final String password = "xxxxxx";
  106.  
  107. Properties props = new Properties();
  108. props.put("mail.smtp.auth", "true");
  109. props.put("mail.smtp.starttls.enable", "true");
  110. props.put("mail.smtp.host", "smtp.gmail.com");
  111. props.put("mail.smtp.port", "587");
  112.  
  113. Session session = Session.getInstance(props,
  114. new javax.mail.Authenticator() {
  115. protected PasswordAuthentication getPasswordAuthentication() {
  116. return new PasswordAuthentication(username, password);
  117. }
  118. });
  119.  
  120. try {
  121.  
  122. Message message = new MimeMessage(session);
  123. message.setFrom(new InternetAddress("luukpook@gmail.com"));
  124. message.setRecipients(Message.RecipientType.TO,
  125. InternetAddress.parse("luukpook@gmail.com"));
  126. message.setSubject("Ticket in winkelwagen");
  127. message.setText("https://www.ticketswap.nl/cart");
  128.  
  129. Transport.send(message);
  130.  
  131. System.out.println("Email sent");
  132.  
  133. } catch (MessagingException e) {
  134. throw new RuntimeException(e);
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement