-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclickybot.py
45 lines (40 loc) · 1.49 KB
/
clickybot.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
#!/usr/bin/env python3
# uses pyautogui to script clicks on an interface
# I use it to keep sessions alive when I can't keep an eye on something
# pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org pyautogui
import sys
import time
import pyautogui
class clicky(object):
_registered_clicky = []
def __init__(self,name,mouse_coordinates):
self._registered_clicky.append(self)
self.name = name
self.coordinates = mouse_coordinates
def main():
def loop_away():
print("Starting to loop in 10 Seconds!")
time.sleep(10)
while True:
for c in clicky._registered_clicky:
cur_position = pyautogui.position()
pyautogui.click(c.coordinates)
print(f"Clicked on {c.name}")
pyautogui.moveTo(cur_position)
time.sleep(60)
while True:
print("Type 'done' to stop picking postions")
name=input("One word name for clickable position: ")
if name.lower()[:4] == 'done':
if clicky._registered_clicky == []:
print("no clicky things to click... exiting")
sys.exit()
else:
loop_away()
print("You have 6 seconds to move the mouse to that position ")
time.sleep(6)
mouse_coordinates = pyautogui.position()
print(f"Captured position at {mouse_coordinates}")
name = clicky(name, mouse_coordinates)
if __name__=="__main__":
main()