Add main.py
This commit is contained in:
62
main.py
Normal file
62
main.py
Normal file
@@ -0,0 +1,62 @@
|
||||
# Imports and all that
|
||||
|
||||
import pynput, time
|
||||
|
||||
Button = pynput.mouse.Button
|
||||
Key = pynput.keyboard.Key
|
||||
Listener = pynput.keyboard.Listener
|
||||
mouse = pynput.mouse.Controller()
|
||||
|
||||
# Variable handling
|
||||
|
||||
def safeToInt(var):
|
||||
try:
|
||||
return int(var)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit(1)
|
||||
|
||||
def safeToFloat(var):
|
||||
try:
|
||||
return float(var)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
exit(1)
|
||||
|
||||
count = safeToInt(input("Amount of clicks: "))
|
||||
timeout = safeToFloat(input("Enter a timeout in seconds: "))
|
||||
stopKey = input('Stop key: ')
|
||||
button = input('LMB, MMB or RMD: ')
|
||||
|
||||
# Actual input simulation
|
||||
|
||||
stop = False
|
||||
|
||||
def on_press(key):
|
||||
global stop
|
||||
if hasattr(key, 'char') and key.char == stopKey:
|
||||
stop = True
|
||||
return False
|
||||
|
||||
Listener(on_press=on_press).start()
|
||||
|
||||
if(button == 'LMB'):
|
||||
if stop:
|
||||
exit(1)
|
||||
for x in range(count):
|
||||
mouse.click(Button.left, 1)
|
||||
time.sleep(timeout)
|
||||
|
||||
if(button == 'MMB'):
|
||||
if stop:
|
||||
exit(1)
|
||||
for x in range(count):
|
||||
mouse.click(Button.left, 1)
|
||||
time.sleep(timeout)
|
||||
|
||||
if(button == 'RMB'):
|
||||
if stop:
|
||||
exit(1)
|
||||
for x in range(count):
|
||||
mouse.click(Button.left, 1)
|
||||
time.sleep(timeout)
|
||||
Reference in New Issue
Block a user