Guest User

Untitled

a guest
Jul 17th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. import java.awt.AWTException;
  2. import java.awt.Robot;
  3. import java.util.Random;
  4. import java.util.Scanner;
  5.  
  6. import static java.awt.event.KeyEvent.*;
  7.  
  8. public class AutoType {
  9. private static int[] letters = {VK_A, VK_B, VK_C, VK_D, VK_E, VK_F, VK_G, VK_H, VK_I, VK_J, VK_K, VK_L, VK_M, VK_N, VK_O, VK_P, VK_Q, VK_R, VK_S, VK_T, VK_U, VK_V, VK_W, VK_X, VK_Y, VK_Z};
  10.  
  11. private static String[] colors = {
  12. "",
  13. "red:",
  14. "green:",
  15. "cyan:",
  16. "purple:",
  17. "white:",
  18. "flash1:",
  19. "flash2:",
  20. "flash3:",
  21. "glow1:",
  22. "glow2:",
  23. "glow3:"
  24. };
  25.  
  26. private static String[] effects = {
  27. "",
  28. "wave:",
  29. "wave2:",
  30. "shake:",
  31. "slide:",
  32. "scroll:"
  33. };
  34.  
  35. private static String[] messages = {
  36. "~~ blessing people for donations ~ pick any god ~~",
  37. "~~ godly blessings for donations ~ god of your choice ~~",
  38. "god choices: armadyl/bandos/guthix/saradomin/zamorak/zaros"
  39. };
  40.  
  41. public static void main(String[] args) throws AWTException {
  42. Robot rob = new Robot();
  43. Random rand = new Random();
  44. Scanner in = new Scanner(System.in);
  45. boolean again = true;
  46.  
  47. while (again) {
  48. for (int j = 0; j < 3; ++j) {
  49. wait(4000 + rand.nextInt(2000));
  50. String randomColor = colors[rand.nextInt(colors.length)];
  51. String randomEffect = effects[rand.nextInt(effects.length)];
  52. String message = randomColor + randomEffect + messages[j];
  53. System.out.println(message);
  54.  
  55. for (int i = 0; i < message.length(); ++i) {
  56. press(rob, message.charAt(i));
  57. wait(10 + rand.nextInt(5));
  58. }
  59.  
  60. press(rob, (char) 0);
  61. }
  62.  
  63. System.out.print("Again? (type anything to continue) ");
  64. again = !in.nextLine().isEmpty();
  65. }
  66. }
  67.  
  68. public static void press(Robot rob, char letter) {
  69. boolean holdShift = letter == '~' || letter == ':';
  70.  
  71. int keyCode =
  72. (letter == ' ') ? VK_SPACE :
  73. (letter == '~') ? VK_BACK_QUOTE :
  74. (letter == '/') ? VK_SLASH :
  75. (letter == ':') ? VK_SEMICOLON :
  76. (letter == '1') ? VK_1 :
  77. (letter == '2') ? VK_2 :
  78. (letter == '3') ? VK_3 :
  79. (letter == 0) ? VK_ENTER :
  80. letters[(letter - 'a')];
  81.  
  82. if (holdShift) {
  83. rob.keyPress(VK_SHIFT);
  84. }
  85.  
  86. rob.keyPress(keyCode);
  87. rob.keyRelease(keyCode);
  88.  
  89. if (holdShift) {
  90. rob.keyRelease(VK_SHIFT);
  91. }
  92. }
  93.  
  94. public static void wait(int ms) {
  95. try {
  96. Thread.sleep(ms);
  97. } catch (InterruptedException e) {
  98. e.printStackTrace();
  99. }
  100. }
  101. }
Add Comment
Please, Sign In to add comment