You can emulate key presses with the "simulate control" action for the platform and 8direction behaviors. For general simulating mouse and keyboard controls I would set some state variables for each control and use the variables in my events instead of the mouse or keyboard conditions. Then simulating a control would be as simple as setting a variable.
I don't think simulating the controls would give an exact replay unless the game ran at the exact same framerate the whole time.
If you want just a visual playback then the game state is unimportant. You just need to save the position,angle,size,opacity or anything that can change visually for each object on screen every frame.
hoanganh17 you say it's for game testing, could you give an example where it would be useful for testing?