Answer the question
In order to leave comments, you need to log in
How to properly record keys for later playback?
I need to make a record of a certain sequence of pressed buttons, on the rack in consequence to play it.
Everything I came up with:
import keyboard
import time
timer = time.time()
timer = round(timer, 2)
dodo = 0
def print_pressed_keys(e):
global dodo
timeTwo = round(time.time(),2)
perem = timeTwo - timer - dodo
perem = round(perem, 2)
dodo += perem
ti = "time.sleep("+ str(perem) + ")\n"
print(ti)
f = open("key_records.txt", 'a')
f.write(ti)
if e.event_type == 'down':
g = "pg.keyDown(@" + str(e.name) + "@)\n"
f.write(g)
else:
g = "pg.keyUp(@" + str(e.name) + "@)\n"
f.write(g)
f.close()
keyboard.hook(print_pressed_keys)
keyboard.wait()
Answer the question
In order to leave comments, you need to log in
1) You need to run as admin for something to work, but for full-fledged movements in the game, you should not use pg.press or keyDown-Up, since the game does not read click data.
2) this library has internal. delay, which makes it...bad.
What other methods are there for this purpose? Help me please!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question