-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainSpaceBarEdition.py
58 lines (49 loc) · 2.78 KB
/
mainSpaceBarEdition.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
from pynput import keyboard, mouse
import time
import os
current = os.getcwd()
os.chdir(current)
########################################################################THIS HAS NO UI########################################################################
is_toggled = False
mouse_controller = mouse.Controller()
keyboard_controller = keyboard.Controller()
COMBINATION = {keyboard.Key.f8}
current_keys = set()
def on_press(key):
if key in COMBINATION:
current_keys.add(key)
if COMBINATION.issubset(current_keys):
global is_toggled
is_toggled = not is_toggled
def on_release(key):
try:
current_keys.remove(key)
except KeyError:
pass
def main():
os.system('cls')
print("Welcome to Bernso's autoclicker!\n\nInformation:\n - The autoclicker is toggleable, you do not hold down the keybind.\n - The keybind to start the autoclicker is 'F8'\n - The deafult delay for this autoclicker is: 0.0001 seconds\n - If the delay is set to 0 IT WILL LAG YOUR COMPUTER and most if not all of your inputs WILL be delayed\n\nWould you like to add a delay? (y/n): ")
user_input = input()
if user_input.lower() == 'y':
delay = float(input("\nEnter the delay in seconds: "))
print(f'Your delay is: {delay}')
print("You can now activate the autoclicker (F8)")
elif user_input.lower() == 'n':
delay = 0.0001
print(f"\nThe delay has automatically been set to: {delay}")
print("You can now activate the autoclicker (F8)")
else:
print("\nInvalid input. When this text disappears the program has been restarted.\nRestarting...")
time.sleep(2)
main()
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
while True:
if is_toggled:
keyboard_controller.press(keyboard.Key.space)
keyboard_controller.release(keyboard.Key.space)
#mouse_controller.press(mouse.Button.left)
#mouse_controller.release(mouse.Button.left)
time.sleep(delay)
listener.join()
if __name__ == "__main__":
main()