main.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import webbrowser
  2. from mss import mss
  3. import numpy as np
  4. from pathlib import Path
  5. import matplotlib.pyplot as plt
  6. from time import sleep
  7. import pyautogui as gui
  8. webbrowser.open('https://chromedino.com/')
  9. with mss() as sct:
  10. # Загрузка динозаврика
  11. path = Path(Path.cwd(), 'trex', 'screenshot.png')
  12. print(path)
  13. sct.shot(output='trex/screenshot.png')
  14. cur_img = plt.imread(path)
  15. sleep(1)
  16. sct.shot(output='trex/screenshot.png')
  17. next_img = plt.imread(path)
  18. time = 0
  19. while not np.all(cur_img == next_img):
  20. time += 1
  21. sleep(1)
  22. cur_img = next_img
  23. sct.shot(output='trex/screenshot.png')
  24. next_img = plt.imread(path)
  25. print(f'loaded for {time} sec')
  26. gui.press('f11')
  27. sleep(0.1)
  28. sct.shot(output='trex/screenshot.png')
  29. cur_img = plt.imread(path)
  30. with gui.hold('space'):
  31. sleep(0.1)
  32. sleep(0.2)
  33. sct.shot(output='trex/screenshot.png')
  34. next_img = plt.imread(path)
  35. dif = np.sum(np.abs(next_img[0] - cur_img[0]))
  36. plt.imshow(dif)
  37. plt.show()