I am trying to make an Emergency quit button but for some reason its not working.
Here is my code:
from pyhooked import Hook, KeyboardEvent, MouseEvent
import pyautogui, os, sys, time
print "to stop Press CONTROl + A\n"
Ammo = raw_input('Enter ammo amount: ')
def handle_events(args):
if isinstance(args, KeyboardEvent):
if args.current_key == 'A' and args.event_type == 'key down' and 'Lcontrol' in args.pressed_key:
hk.exit()
if args.current_key == 'B' and args.event_type == 'key down' and 'Lcontrol' in args.pressed_key:
for i in range(int(Ammo)):
(pyautogui.click(button='right'))
(pyautogui.moveRel(2, 2, duration=0.01))
(pyautogui.click(button='right'))
(pyautogui.moveRel(-2, -2, duration=1.58))
hk = Hook()
hk.handler = handle_events
hk.hook()
It is designed so that I can run the program then go to the game and click my keybind connected to my program to run its action. Then it will do this action when I leave my computer saving me time.
But when I come back to my computer, I need to be able to take control of it again but my Close program keybind does not work.
The keybind to start the action is CTRL + B then when I want to exit the program I need the CTRL + A keybind to override the CTRL + B action and close the program.