
The only way to play both events at the same time is to use threading Keyboard_events = keyboard.stop_recording() #Stopping the recording. Keyboard.start_recording() #Starting the recording So your final code will look like this: import mouse Mouse module doesn't have stop/ start_recording It doesn't take a callback and you can record once at a time.Ģ) stop_recording() to stop the started recording. Use start_recording() and stop_recording()ġ) start_recording() to enable the recording of keyboard events. There is more simpler way to do this without using hook but its only for module keyboard You can solve this by using lambda: keyboard.hook(lambda _: keyboard_events.append(_)) The error is thrown because the module keyboard uses dict for hook unlike module mouse and you can't use list as keys. Looks like you forgot to modify the code. So, to summarize: How can I start the mouse and keyboard recording at the same moment, stop them both at the same time and run both simultaneously? Are the mouse and keyboard modules the best option to achieve this?īut you are using events.append rather than the list name. I tried to check the module files but I fail to understand most of it.

The keyboard.hook(events.append) line in the code above throws an error: As both modules were made by the same people, I assumed that the same would work with the keyboard module. Mouse.unhook(events.append) #Stopping the mouse recording Keyboard.wait("a") #Waiting for 'a' to be pressed Mouse.hook(events.append) #starting the mouse recording

#Keyboard and mouse recorder windows free how to
In an earlier question, I asked how to record the mouse movement until a key is pressed, and I got the following code: import mouseĮvents = #This is the list where all the events will be stored

I think that this can be achieved with the keyboard and mouse modules. I want to create a function that records both mouse and keyboard events until a specific key is pressed and then replays them together.
