Recording GUI events (button clicks, etc.) has very limited use (only for testing, and even there it is quite fragile). Meaningful workflow automation Python scripts should operate at lower level, by changing properties of MRML nodes and calling module logic functions.
I’ve recently implemented a simple Python script that observes all MRML node changes and generate a list of node property modifications (by comparing MRML node PrintSelf results before and after the node modification). This can be used to generate a runnable, user-editable Python script. This is similar to what Paraview can do. However, this turned out not to be very useful, because it is too low level (for a single user action you get a bunch of node property modification events, but you don’t know why the node ended up being modified like that).
What we would really need is an intermediate level, where a user action is translated to a few high-level method calls. I’m not sure what is the easiest way to achieve this. Maybe we could add a specially formatted log message whenever a logic method is called (and macro recording is enabled), and these could be easily converted to runnable Python code.