Automate refactoring of code.

I’d like to automate a refactor actions.

What I usually do is:

  1. Press: command + k (to open the popup)

  2. Type: refactor it

  3. Press: enter (to start AI)

  4. Press: command + enter (to accept)

I’ve installed multi-command tool and I managed to emulate command + k by running aipopup.action.modal.generate command. But then I can’t emulate interaction with the popup. Any help?