-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguiautomate.py
executable file
·51 lines (36 loc) · 1.27 KB
/
guiautomate.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
import argparse
from control.MouseRoutine import MouseRoutine
def record(abspath: bool, path: str):
routine = MouseRoutine()
routine.record()
if abspath:
routine.save(path)
else:
routine.save(f"routines/{path}")
def play(abspath: bool, path: str):
routine = MouseRoutine()
if abspath:
routine.load(path)
else:
routine.load(f"routines/{path}")
routine.play()
mode = {
"record": record,
"play": play,
}
def main(args: argparse.Namespace):
# If user provided path is absolute or ~
abspath = args.path[0] == "/" or args.path[0] == "~"
do = mode.get(args.mode)
do(abspath, args.path)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="A GUI Automater Program")
parser.add_argument("--mode",
choices=["record", "play"],
help="Record mode records a new routine. Play mode plays back a saved routine.",
required=True)
parser.add_argument("--path",
type=str,
help="Path of routine to play or record. If not an absolute or ~ path, routines will be stored in routines dir.",
required=True)
main(parser.parse_args())