-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoClicker.py
More file actions
46 lines (37 loc) · 1.1 KB
/
Copy pathAutoClicker.py
File metadata and controls
46 lines (37 loc) · 1.1 KB
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
import time
import win32api as wapi
import win32con as wcon
from getKeys import key_check
class AutoClicker:
def __init__(self, x, y, rate):
self.x = x
self.y = y
self.moveCursor(self.x, self.y)
self.rate = rate
self.paused = False
self.stop = False
# Perform left mouse click at coordinates (x, y)
def click(self):
wapi.mouse_event(wcon.MOUSEEVENTF_LEFTDOWN, self.x, self.y, 0, 0)
wapi.mouse_event(wcon.MOUSEEVENTF_LEFTUP, self.x, self.y, 0, 0)
def moveCursor(self, x, y):
self.x = x
self.y = y
wapi.SetCursorPos((self.x, self.y))
# Start auto clicking
def start(self):
while True:
if not self.paused:
self.click()
#print("Click!")
time.sleep(self.rate) # delay
self.checkPause()
if self.stop:
break
# Check for pause conditions
def checkPause(self):
keys = key_check()
if 'P' in keys:
self.paused = not self.paused
if 'Q' in keys:
self.stop = True