Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyautogui
- import numpy as np
- import time
- from PIL import Image
- im = Image.open("./image.bmp")
- w, h = pyautogui.size()
- im_w, im_h = im.size
- im2 = im.resize((int(im_w/(im_h/50)), 50), Image.CUBIC)
- img_arr = np.array(im2)
- chng_color_pos = (1128, 83)
- chng_color_ok_pos = (491, 508)
- red_pos = (885, 438)
- green_pos = (885, 461)
- blue_pos = (885, 485)
- white_color = np.array([255, 255, 255])
- color_inputs = red_pos, green_pos, blue_pos
- # while True:
- # print(pyautogui.position())
- # time.sleep(1/60)
- coord_field = (6, 145)
- time.sleep(2)
- last_color = None
- for x, line_n in enumerate(range(len(img_arr))):
- line = img_arr[line_n]
- for y, point_n in enumerate(range(len(line))):
- point = line[point_n]
- if not np.array_equal(point, white_color):
- if not np.array_equal(point, last_color):
- last_color = point
- pyautogui.leftClick(*chng_color_pos)
- for color, coord in zip(point, color_inputs):
- pyautogui.leftClick(*coord, _pause=False)
- pyautogui.press('del', 3, _pause=False)
- pyautogui.write(str(color), _pause=False)
- pyautogui.leftClick(*chng_color_ok_pos)
- pyautogui.leftClick(coord_field[0]+line_n+(x*5), coord_field[1]+point_n+(y*5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement