Skip to content

Commit

Permalink
fix error on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
lippielip committed Dec 29, 2021
1 parent df2ab79 commit a4e2cd0
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/antiafk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
3: 'w',
4: 's'}

# define our clear function
def clear():

# for windows
if name == 'nt':
_ = system('cls')

# for mac and linux
else:
_ = system('clear')

def is_admin():
try:
Expand Down Expand Up @@ -154,29 +164,23 @@ def is_combination_pressed(combination):

def on_press(key):
""" When a key is pressed """
vk = get_vk(key) # Get the key's vk
pressed_vks.add(vk) # Add it to the set of currently pressed keys

for combination in combination_to_function: # Loop through each combination
if is_combination_pressed(combination): # Check if all keys in the combination are pressed
threading.Thread(target=combination_to_function[combination]).start() # If so, execute the function in a new thread
try:
vk = get_vk(key) # Get the key's vk
pressed_vks.add(vk) # Add it to the set of currently pressed keys

for combination in combination_to_function: # Loop through each combination
if is_combination_pressed(combination): # Check if all keys in the combination are pressed
threading.Thread(target=combination_to_function[combination]).start() # If so, execute the function in a new thread
except:
pass

def on_release(key):
""" When a key is released """
vk = get_vk(key) # Get the key's vk
pressed_vks.remove(vk) # Remove it from the set of currently pressed keys

# define our clear function
def clear():

# for windows
if name == 'nt':
_ = system('cls')

# for mac and linux
else:
_ = system('clear')
try:
vk = get_vk(key) # Get the key's vk
pressed_vks.remove(vk) # Remove it from the set of currently pressed keys
except:
pass

clear()
print('Anti-AFK Bot initialized. Enable/Disable with Shift+0')
Expand Down

0 comments on commit a4e2cd0

Please sign in to comment.