-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathAutoPlay.py
More file actions
32 lines (26 loc) · 698 Bytes
/
AutoPlay.py
File metadata and controls
32 lines (26 loc) · 698 Bytes
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
from Util import time_it
from ImgTools import recognize
import os
from PIL import Image
def get_screenshot():
os.system('adb exec-out screencap -p > screenshot.png')
scr = Image.open('screenshot.png')
scr = scr.crop([0, 700, 1080, 1200])
return scr
@time_it
def Play():
flag = ""
while True:
scr = get_screenshot()
expr = recognize(scr)
print(expr, eval(expr))
if flag == expr:
continue
else:
flag = expr
if eval(expr):
os.system("adb shell input tap 300 1500")
else:
os.system("adb shell input tap 800 1500")
if __name__ == '__main__':
Play()