Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.21 KB | None | 0 0
  1. private class myLogBot {
  2. private int INTERFACE_MAIN = 905,INTERFACE_MAIN_CHILD = 59,INTERFACE_MAIN_CHILD_COMPONENT_ID = 4,INTERFACE_LOGIN_SCREEN = 596
  3. ,INTERFACE_USERNAME = 59,INTERFACE_USERNAME_WINDOW = 55,INTERFACE_PASSWORD = 73,INTERFACE_PASSWORD_WINDOW = 62
  4. ,INTERFACE_BUTTON_LOGIN = 63,INTERFACE_TEXT_RETURN = 15,INTERFACE_WELCOME_SCREEN = 906,INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_1 = 178,
  5. INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_2 = 180,INTERFACE_WELCOME_SCREEN_TEXT_RETURN = 36;
  6.  
  7. private int INDEX_LOGGED_OUT = 3,INDEX_LOBBY = 7, invalidCount, worldFullCount;
  8.  
  9. private void login(String Username,String Pass) {
  10. while (game.getClientState() == 3 || game.getClientState() == 7) {
  11. manualLog(Username,Pass);
  12. sleep(random(500,1000));
  13. }
  14. }
  15. private int manualLog(String Username,String Pass) {
  16. String username = Username.replaceAll("_", " ").toLowerCase().trim();
  17. String returnText = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_TEXT_RETURN).getText().toLowerCase();
  18. int textlength;
  19.  
  20. if (game.getClientState() != INDEX_LOGGED_OUT) {
  21. if (!game.isWelcomeScreen()) {
  22. sleep(random(1000, 2000));
  23. }
  24. if (game.getClientState() == INDEX_LOBBY) {
  25. RSInterface welcome_screen = interfaces.get(INTERFACE_WELCOME_SCREEN);
  26. RSComponent welcome_screen_button_play_1 = welcome_screen.getComponent(INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_1);
  27. RSComponent welcome_screen_button_play_2 = welcome_screen.getComponent(INTERFACE_WELCOME_SCREEN_BUTTON_PLAY_2);
  28.  
  29. mouse.click(
  30. welcome_screen_button_play_1.getAbsoluteX(),
  31. welcome_screen_button_play_1.getAbsoluteY(),
  32. welcome_screen_button_play_2.getAbsoluteX() + welcome_screen_button_play_2.getWidth() - welcome_screen_button_play_1.getAbsoluteX(),
  33. welcome_screen_button_play_1.getHeight(),
  34. true
  35. );
  36.  
  37. for (int i = 0; i < 4 && game.getClientState() == 6; i++) {
  38. sleep(500);
  39. }
  40. returnText = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(INTERFACE_WELCOME_SCREEN_TEXT_RETURN).getText().toLowerCase();
  41.  
  42. if (returnText.contains("members")) {
  43. log("Unable to login to a members world. Stopping script.");
  44. RSComponent back_button1 = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(38);
  45. RSComponent back_button2 = interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(41);
  46. mouse.click(back_button1.getAbsoluteX(),back_button1.getAbsoluteY(),
  47. back_button2.getAbsoluteX() + back_button2.getWidth() - back_button1.getAbsoluteX(),
  48. back_button1.getHeight(),true);
  49. interfaces.get(INTERFACE_WELCOME_SCREEN).getComponent(203).doClick();
  50. stopScript(false);
  51. }
  52. }
  53. return -1;
  54. }
  55. if (!game.isLoggedIn()) {
  56. if (returnText.contains("update")) {
  57. log("Runescape has been updated, please reload RSBot.");
  58. stopScript(false);
  59. }
  60. if (returnText.contains("disable")) {
  61. log("Your account is banned/disabled.");
  62. stopScript(false);
  63. }
  64. if (returnText.contains("incorrect")) {
  65. log("Failed to login five times in a row. Stopping script.");
  66. stopScript(false);
  67. }
  68. if (returnText.contains("invalid")) {
  69. if (invalidCount > 6) {
  70. log("Unable to login after 6 attempts. Stopping script.");
  71. log("Please verify that your RSBot account profile is correct.");
  72. stopScript(false);
  73. }
  74. interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(25).doClick();
  75. invalidCount++;
  76. return (random(500, 2000));
  77. }
  78. if (returnText.contains("full")) {
  79. if (worldFullCount > 30) {
  80. log("World Is Full. Waiting for 15 seconds.");
  81. sleep(random(10000, 15000));
  82. worldFullCount = 0;
  83. }
  84. sleep(random(1000, 1200));
  85. worldFullCount++;
  86. }
  87. if (returnText.contains("world")) {
  88. return random(1000, 1200);
  89. }
  90. if (returnText.contains("performing login")) {
  91. return random(1000, 1200);
  92. }
  93. }
  94. if (game.getClientState() == INDEX_LOGGED_OUT) {
  95. if (!atLoginScreen()) {
  96. interfaces.getComponent(INTERFACE_MAIN, INTERFACE_MAIN_CHILD).getComponent(INTERFACE_MAIN_CHILD_COMPONENT_ID).doAction("");
  97. return random(500, 600);
  98. }
  99. if (isUsernameFilled(Username) && isPasswordFilled(Pass)) {
  100. interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_BUTTON_LOGIN).doClick();
  101. return random(500, 600);
  102. }
  103. if (!isUsernameFilled(Username)) {
  104. atLoginInterface(interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME_WINDOW));
  105. sleep(random(500, 700));
  106. textlength = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME).getText().length() + random(3, 5);
  107. for (int i = 0; i <= textlength + random(1, 5); i++) {
  108. keyboard.sendText("\b", false);
  109. if (random(0, 2) == 1) {
  110. sleep(random(25, 100));
  111. }
  112. }
  113. keyboard.sendText(username, false);
  114. return random(500, 600);
  115. }
  116. if (isUsernameFilled(Username) && !isPasswordFilled(Pass)) {
  117. atLoginInterface(interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD_WINDOW));
  118. sleep(random(500, 700));
  119. textlength = interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().length() + random(3, 5);
  120. for (int i = 0; i <= textlength + random(1, 5); i++) {
  121. keyboard.sendText("\b", false);
  122. if (random(0, 2) == 1) {
  123. sleep(random(25, 100));
  124. }
  125. }
  126. keyboard.sendText(Pass, false);
  127. }
  128. }
  129. return random(500, 2000);
  130. }
  131. private boolean atLoginInterface(RSComponent i) {
  132. if (!i.isValid())
  133. return false;
  134. Rectangle pos = i.getArea();
  135. if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
  136. return false;
  137. int dy = (int) (pos.getHeight() - 4) / 2;
  138. int maxRandomX = (int) (pos.getMaxX() - pos.getCenterX());
  139. int midx = (int) (pos.getCenterX());
  140. int midy = (int) (pos.getMinY() + pos.getHeight() / 2);
  141. if (i.getIndex() == INTERFACE_PASSWORD_WINDOW) {
  142. mouse.click(minX(i), midy + random(-dy, dy), true);
  143. } else {
  144. mouse.click(midx + random(1, maxRandomX), midy + random(-dy, dy), true);
  145. }
  146. return true;
  147. }
  148. private int minX(RSComponent a) {
  149. int x = 0;
  150. Rectangle pos = a.getArea();
  151. int dx = (int) (pos.getWidth() - 4) / 2;
  152. int midx = (int) (pos.getMinX() + pos.getWidth() / 2);
  153. if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1)
  154. return 0;
  155. for (int i = 0; i < interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().length(); i++) {
  156. x += 11;
  157. }
  158. if (x > 44) {
  159. return (int) (pos.getMinX() + x + 15);
  160. } else {
  161. return midx + random(-dx, dx);
  162. }
  163. }
  164. private boolean atLoginScreen() {
  165. return interfaces.get(596).isValid();
  166. }
  167. private boolean isUsernameFilled(String Username) {
  168. String username = Username.replaceAll("_", " ").toLowerCase().trim();
  169. return interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_USERNAME).getText().toLowerCase().equalsIgnoreCase(username);
  170. }
  171. private boolean isPasswordFilled(String Password) {
  172. return interfaces.get(INTERFACE_LOGIN_SCREEN).getComponent(INTERFACE_PASSWORD).getText().toLowerCase().length() == Password.length();
  173. }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement