inposition

Open Packs for Hearthstone Forged in the Barrens

Feb 25th, 2021 (edited)
2,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.53 KB | None | 0 0
  1. import java.awt.AWTException;
  2. import java.awt.Robot;
  3. import java.awt.event.InputEvent;
  4. import java.awt.event.KeyEvent;
  5.  
  6. public class OP {
  7.     Robot robot = new Robot();
  8.  
  9.  
  10.     public static void main(String[] args) throws AWTException {
  11.         new OP();
  12.     }
  13.  
  14.     public OP() throws AWTException {
  15.  
  16. ////////////////////////////////////////////////////////////////
  17. ////    CHANGE THESE VARIABLES TO CONTROL THE PROGRAM      ////
  18.         int numPacks = 3;  // SET THE NUMBER OF PACKS TO OPEN HERE
  19.         boolean screenShot = false;  // true if you want screenshots, false if not
  20. ////////////////////////////////////////////////////////////////
  21.  
  22. ////  Set your screen resolution to 1920x1080
  23.        
  24.         robot.setAutoDelay(40);
  25.         robot.setAutoWaitForIdle(true);
  26.  
  27.         robot.delay(3000);  // give 5 seconds to move you mouse to the game screen
  28.         // Make sure to click on the game screen anywhere
  29.  
  30.         while (numPacks > 0) {
  31.  
  32.             type("Opening pack...\n");
  33.             openPack(screenShot);
  34.  
  35.             numPacks = numPacks - 1;
  36.             robot.delay(100);
  37.         }
  38.  
  39.         robot.delay(100);
  40.         System.exit(0);
  41.     }
  42.  
  43.     private void openPack(boolean screenShot) {
  44.         //set pack
  45.         type(KeyEvent.VK_SPACE); // set pack
  46.         //int TOP = 260;
  47.         //int MIDDLE = 520;
  48.         //int BOTTOM = 800; // UNTESTED
  49.         //setPack(MIDDLE);
  50.         robot.delay(2000);
  51.         robot.mouseMove(1120, 260);  // CARD 1      //System.exit(0);
  52.         robot.delay(100);
  53.         leftClick();
  54.         robot.delay(50);
  55.         robot.mouseMove(1420, 375);  // CARD 2
  56.         robot.delay(50);
  57.         leftClick();
  58.         robot.delay(50);
  59.         robot.mouseMove(1280, 800);  // CARD 3
  60.         robot.delay(50);
  61.         leftClick();
  62.         robot.delay(50);
  63.         robot.mouseMove(970, 790);  // CARD 4
  64.         robot.delay(50);
  65.         leftClick();
  66.         robot.delay(50);
  67.         robot.mouseMove(810, 375);  // CARD 5
  68.         robot.delay(50);
  69.         leftClick();
  70.         robot.delay(50);
  71.         robot.mouseMove(1120, 580);  // DONE
  72.         robot.delay(1200);
  73.  
  74.         if (screenShot) {
  75.             // get the screenshot
  76.             robot.keyPress(KeyEvent.VK_PRINTSCREEN);
  77.             robot.delay(40);
  78.             robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
  79.             robot.delay(40);
  80.         }
  81.  
  82.         leftClick();
  83.         robot.delay(100);
  84.  
  85.     }
  86.  
  87.     private void leftClick() {
  88.         robot.mousePress(InputEvent.BUTTON1_MASK);
  89.         robot.delay(100);
  90.         robot.mouseRelease(InputEvent.BUTTON1_MASK);
  91.         robot.delay(100);
  92.     }
  93.  
  94.     private void type(int i) {
  95.         robot.delay(40);
  96.         robot.keyPress(i);
  97.         robot.keyRelease(i);
  98.     }
  99.  
  100.     private void type(String s) {
  101.         byte[] bytes = s.getBytes();
  102.         for (byte b : bytes) {
  103.             int code = b;
  104.             // keycode only handles [A-Z] (which is ASCII decimal [65-90])
  105.             if (code > 96 && code < 123) code = code - 32;
  106.             robot.delay(40);
  107.             robot.keyPress(code);
  108.             robot.keyRelease(code);
  109.         }
  110.     }
  111.  
  112.     //private void setPack(int PACKPOSITION)
  113.     //{
  114.     //robot.mouseMove(400, PACKPOSITION);  // CARD 1
  115. //    robot.delay(200);
  116. //    robot.mousePress(InputEvent.BUTTON1_MASK);
  117. //    robot.mouseMove(1120, 580);
  118. //    robot.delay(200);
  119. //    robot.mouseRelease(InputEvent.BUTTON1_MASK);
  120.     //System.exit(0);
  121. //    robot.delay(200);
  122. //  }
  123.  
  124. } // End OP
  125.  
  126. // (c) Copyright inposition .  I'm in position
  127.  
Add Comment
Please, Sign In to add comment