There was (still is) a very popular program called BOME Midi Translator that did something similar - think of it like AutoHotKey but specifically for midi.
Back when I made heavy use of Kontakt libraries I got frustrated at the lack of an easy way to audition the patches (of which there could be hundreds on a single sampler). To get around it, I created a Bome script so when I pressed an unused button on my midi controller it would trigger a mouse click to advance to the next patch in my DAW and then send a note-on / note-off for C4 for half a second.
Made previewing the sounds much easier.
smokel•1h ago