0

So it just breaks when holding down while holding down SHIFT ALT or CTRL While the function is running, When It does break I do try tapping SHIFT ALT and CTRL to see if they are stuck down and they aren't so I'm all out of ideas.

import time
import pyautogui
import random

def feint():
    number = random.randint(1,4)
    print('1')
    if number == 1:
        pyautogui.keyDown('LEFT')
        pyautogui.mouseDown()
        pyautogui.keyUp('LEFT')
        time.sleep(0.1)
        pyautogui.keyDown('ctrl')
        pyautogui.keyUp('ctrl')
        pyautogui.mouseUp()
    if number == 2:
        #ETC

The feint2() Is just the same code twice with already used options out of play and the attack is the same as the feint() without the pyautogui.keyDown('ctrl') pyautogui.keyUp('ctrl')

import pyautogui
import random
import feinter
from attacker import attack
import keyboard

pyautogui.FAILSAFE = False

def feintmarco():
    number = random.randint(1,2)
    if number == 1:
        feinter.feint()
        print('0')
        attack()
    if number == 2:
        feinter.feint2()
        print('0')
        attack()
keyboard.add_hotkey('Num -', feintmarco)
keyboard.wait()
  • You're not passing anything to `wait()`. From the [source code](https://github.com/boppreh/keyboard/blob/master/keyboard/__init__.py#L991) of the `keyboard` module, you can clearly see that if nothing is passed in, the script will just loop forever with `_time.sleep(1e6)`. Notice the "`or, if given no parameters, blocks forever.`" part. You need to specify which key you are waiting for. – Random Davis May 10 '22 at 19:43
  • @RandomDavis Even when adding `keyboard.wait('=')` the code still gets stuck by the same rules as before. Even when pressing the wait key. – Tasty Bison May 10 '22 at 19:54
  • I don't understand what you want to do. And what `SHIFT ALT or CTRL` has to do with this problem. Maybe first test script only with `keyboard.wait("=")` . Maybe it has some conflict with other code which we can't see. OR maybe it has conflict with `pyautogui` which has functions to send keys to system. – furas May 10 '22 at 20:34
  • @furas That's what I don't understand and it works if I don't use SHIFT ALT or CTRL at all Both the wait and the hotkey but I need to hold shift for most Marco to be effective. I could post the feinter and attack codes too. – Tasty Bison May 10 '22 at 20:37
  • if you have to keep `SHIFT ALT or CTRL` then you should use different hotkeys - with `SHIFT ALT or CTRL` - because for system `=`and `Shift+=` and `Ctrl+=`, `Ctrl+Shift+=`, `Ctrl+Shift+Alt+=` are 5 different hotkeys. – furas May 10 '22 at 21:03
  • for single key you can use `keyboard.on_press_key('=', your_function)` and it will run function when you press `=` or `Shift+=`, `Ctrl+=`, `Ctrl+Shift+=`, `Ctrl+Shift+Alt+=`, etc. – furas May 10 '22 at 21:14
  • When using `keyboard.on_press_key('=', your_function)` I have to Loop it with a `while True` and it causes issues delaying the keyboard Doing it with `keyboard.wait('=')` doesnt seem to actually work at all Also I think most the keys on the keyboard if not all of them react differently when pressing **SHIFT ALT** or **CTRL**. If I could add mutiple hotkeys to do the same thing it wouldn't be too bad but I get bad reactions from that too. – Tasty Bison May 11 '22 at 09:25
  • Even when adding `keyboard.add_hotkey('Num -', feintmarco) keyboard.add_hotkey('SHIFT + Num -', feintmarco) keyboard.add_hotkey('SHIFT + Num - + W', feintmarco)` and so forth it still gets caught up on nothing. – Tasty Bison May 11 '22 at 09:27

0 Answers0