Guest User

CalibrateGameScreen.py

a guest
Jan 9th, 2018
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #auto calibrate game area.
  2. import pyautogui
  3. import pyscreenshot as ImageGrab
  4. from time import sleep
  5.  
  6.  
  7. def autoCalibrate ():
  8.     topLeft  = pyautogui.locateOnScreen('hold.png')
  9.     bottomRight = pyautogui.locateOnScreen('next.png')
  10.  
  11.     x_pad = topLeft[0] - 62
  12.     y_pad = topLeft[1] - 47
  13.     x_width = bottomRight[0] + 226 #far right of image
  14.     y_length = bottomRight[1] + 550 #far bottom of image
  15.  
  16.     return (x_pad, y_pad, x_width, y_length)
  17.  
  18.  
  19.  
  20. if __name__ == "__main__":
  21.     sleep(5)
  22.  
  23.     x_pad, y_pad, x_width, y_length = autoCalibrate()
  24.  
  25.     print("\n Copy these values down. We'll need them later")
  26.     print("x_pad=" + str(x_pad) + " " + "y_pad=" + str(y_pad) + " " + "x_width=" + str(x_width) + " " + "y_length=" + str(y_length))
  27.     im=ImageGrab.grab(bbox =(x_pad,y_pad,x_width,y_length))
  28.     im.save("GAMESCREEN1.png")
  29.     im.show()
RAW Paste Data