Honestly, Hammerspoon is an awesome tool to automate your macOS computer. It can react to system events, keyboard shortcuts and much more. Just have a look at its API and the Getting Started Guide. It is made for people that are not afraid to use an editor and code in the sweet programming language Lua. If you can code, it is more then sufficient to take a look at Learn Lua in Y Minutes to get a good grasp of Lua.