-
Notifications
You must be signed in to change notification settings - Fork 3
/
auto-drive-chatgpt.py
executable file
·94 lines (73 loc) · 2.11 KB
/
auto-drive-chatgpt.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
"""
A simple script
Usage:
./template_py_scripts.py -h
./template_py_scripts.py -v # To log INFO messages
./template_py_scripts.py -vv # To log DEBUG messages
"""
import logging
import time
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import pyautogui
def setup_logging(verbosity):
logging_level = logging.WARNING
if verbosity == 1:
logging_level = logging.INFO
elif verbosity >= 2:
logging_level = logging.DEBUG
logging.basicConfig(
handlers=[
logging.StreamHandler(),
],
format="%(asctime)s - %(filename)s:%(lineno)d - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
level=logging_level,
)
logging.captureWarnings(capture=True)
def parse_args():
parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
parser.add_argument(
"-v",
"--verbose",
action="count",
default=0,
dest="verbose",
help="Increase verbosity of logging output",
)
return parser.parse_args()
def show_position():
while True:
# Get the current mouse position.
mouse_position = pyautogui.position()
# Print the current mouse position.
print(mouse_position)
# Sleep for 1 second.
time.sleep(1)
def move_to_prompt_box():
pyautogui.moveTo(828, 921)
pyautogui.click()
time.sleep(1)
pyautogui.click()
def send_prompt():
# pyautogui.moveTo(1480, 925)
# pyautogui.click()
pyautogui.hotkey("command", "enter")
time.sleep(30)
def main(args):
# Get the current mouse position.
# show_position()
with open("sample/dev-prompt.txt") as file:
data = file.read().split("---")
data = [section.strip() for section in data if section.strip() != ""]
for prompt in data:
print(f"Running Prompt: {prompt}")
move_to_prompt_box()
pyautogui.write(prompt)
# pyautogui.press("Enter")
time.sleep(1)
send_prompt()
if __name__ == "__main__":
args = parse_args()
setup_logging(args.verbose)
main(args)