Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #auto calibrate game area.
- import pyautogui
- import pyscreenshot as ImageGrab
- from time import sleep
- def autoCalibrate ():
- topLeft = pyautogui.locateOnScreen('hold.png')
- bottomRight = pyautogui.locateOnScreen('next.png')
- x_pad = topLeft[0] - 62
- y_pad = topLeft[1] - 47
- x_width = bottomRight[0] + 226 #far right of image
- y_length = bottomRight[1] + 550 #far bottom of image
- return (x_pad, y_pad, x_width, y_length)
- if __name__ == "__main__":
- sleep(5)
- x_pad, y_pad, x_width, y_length = autoCalibrate()
- print("\n Copy these values down. We'll need them later")
- print("x_pad=" + str(x_pad) + " " + "y_pad=" + str(y_pad) + " " + "x_width=" + str(x_width) + " " + "y_length=" + str(y_length))
- im=ImageGrab.grab(bbox =(x_pad,y_pad,x_width,y_length))
- im.save("GAMESCREEN1.png")
- im.show()
Add Comment
Please, Sign In to add comment