-
Notifications
You must be signed in to change notification settings - Fork 1
/
visual_test.py
52 lines (44 loc) · 1.7 KB
/
visual_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from PIL import ImageGrab
from pynput.mouse import Button, Controller
import time
from ctypes import windll
import sys
limit = 20
if (len(sys.argv) == 1):
print("No limit specified, using default of %i" % (limit))
print("Usage example: python %s 30" % (sys.argv[0]))
elif (sys.argv[1].isdigit()):
limit = int(sys.argv[1])
else:
print("Invalid argument.")
print("Usage example: python %s 30" % (sys.argv[0]))
sys.exit(1)
mouse = Controller()
image = None
screensize = windll.user32.GetSystemMetrics(
0), windll.user32.GetSystemMetrics(1)
if (screensize[0] == 1920 and screensize[1] == 1080):
mouse.position = (954, 558)
elif (screensize[0] == 2560 and screensize[1] == 1440):
mouse.position = (1273, 558)
else:
print("Sorry, your resolution is not supported.")
sys.exit(1)
mouse.click(Button.left, 1)
time.sleep(1)
# can't use variables for width / height, as bbox apparently doesn't work well with variables...
for x in range(0, limit):
if (screensize[0] == 1920 and screensize[1] == 1080):
image = ImageGrab.grab(bbox=(750, 259, 1150, 659))
elif (screensize[0] == 2560 and screensize[1] == 1440):
image = ImageGrab.grab(bbox=(1072, 259, 1472, 659))
time.sleep(1.1)
for i in range(0, 400, 20):
for j in range(0, 400, 20):
if image.getpixel((i, j)) == (255, 255, 255):
if (screensize[0] == 1920 and screensize[1] == 1080):
mouse.position = (i + 750, j + 259)
elif (screensize[0] == 2560 and screensize[1] == 1440):
mouse.position = (i + 1072, j + 259)
mouse.click(Button.left, 1)
time.sleep(2)