While this isn’t a code, here’s a nudge: There are some people/companies/developers you feel you have to pay, and some you actually enjoy giving money because they do such a great job or make a big contribution to the world. For me, this is one of them.
Keyboard Maestro is a great, mature, product that is continually improved. It comes with a fantastic community of supporters, and an extremely responsive developer.