Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. import pyautogui
  2. import numpy as np
  3. import time
  4. from PIL import Image
  5.  
  6.  
  7. im = Image.open("./image.bmp")
  8. w, h = pyautogui.size()
  9. im_w, im_h = im.size
  10.  
  11. im2 = im.resize((int(im_w/(im_h/50)), 50), Image.CUBIC)
  12. img_arr = np.array(im2)
  13.  
  14. chng_color_pos = (1128, 83)
  15. chng_color_ok_pos = (491, 508)
  16. red_pos = (885, 438)
  17. green_pos = (885, 461)
  18. blue_pos = (885, 485)
  19.  
  20. white_color = np.array([255, 255, 255])
  21.  
  22. color_inputs = red_pos, green_pos, blue_pos
  23.  
  24. # while True:
  25. #     print(pyautogui.position())
  26. #     time.sleep(1/60)
  27.  
  28. coord_field = (6, 145)
  29. time.sleep(2)
  30.  
  31. last_color = None
  32.  
  33. for x, line_n in enumerate(range(len(img_arr))):
  34.     line = img_arr[line_n]
  35.     for y, point_n in enumerate(range(len(line))):
  36.         point = line[point_n]
  37.         if not np.array_equal(point, white_color):
  38.             if not np.array_equal(point, last_color):
  39.                 last_color = point
  40.                 pyautogui.leftClick(*chng_color_pos)
  41.                 for color, coord in zip(point, color_inputs):
  42.                     pyautogui.leftClick(*coord, _pause=False)
  43.                     pyautogui.press('del', 3, _pause=False)
  44.                     pyautogui.write(str(color), _pause=False)
  45.                 pyautogui.leftClick(*chng_color_ok_pos)
  46.             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