-
Notifications
You must be signed in to change notification settings - Fork 0
/
trex_getData.py
73 lines (37 loc) · 1.1 KB
/
trex_getData.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import keyboard
import uuid
import time
from PIL import Image
from mss import mss
"""
http://www.trex-game.skipser.com/
"""
mon = {"top":300, "left":770, "width":250, "height":100}
sct = mss()
i = 0
def record_screen(record_id, key):
global i
i += 1
print("{}: {}".format(key, i))
img = sct.grab(mon)
im = Image.frombytes("RGB", img.size, img.rgb)
im.save("./img/{}_{}_{}.png".format(key, record_id, i))
is_exit = False
def exit():
global is_exit
is_exit = True
keyboard.add_hotkey("esc", exit)
record_id = uuid.uuid4()
while True:
if is_exit: break
try:
if keyboard.is_pressed(keyboard.KEY_UP):
record_screen(record_id, "up")
time.sleep(0.1)
elif keyboard.is_pressed(keyboard.KEY_DOWN):
record_screen(record_id, "down")
time.sleep(0.1)
elif keyboard.is_pressed("right"):
record_screen(record_id, "right")
time.sleep(0.1)
except RuntimeError: continue