Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

python - Combine keyboard macros with hotkey?

I'm trying to build a macro for a fighting game and I think I'm going about this the wrong way. Can I store these series of actions as their own objects? I have it set up to perform the series of keys to perform a skill but what if I want to combine the skills with a single hotkey? Like:

 keyboard.is_pressed('1'): 
 Skill1(), Skill2()

This is my code;

def Skills():
    while True:
            #Skill 1
            if keyboard.is_pressed('1'):
                keyboard.press_and_release("q")
                time.sleep(0.1)
                keyboard.press_and_release("q")
                time.sleep(0.1)
                keyboard.press_and_release("q")
                time.sleep(0.1)
                keyboard.press_and_release("r")
                time.sleep(0.1)
                keyboard.press_and_release("d")
            #Skill 2
            if keyboard.is_pressed('2'):
                keyboard.press_and_release("e")
                time.sleep(0.1)
                keyboard.press_and_release("e")
                time.sleep(0.1)
                keyboard.press_and_release("e")
                time.sleep(0.1)
                keyboard.press_and_release("r")
                time.sleep(0.1)
                keyboard.press_and_release("d")
Skills()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...