The hard and fast rule that I have heard time and time again is: Only one action per button press with anything that isn't an in-game macro or addon.
So, for example, you can't have an outside program send keys 2-5 every time you press the 1 key so that it fires off whatever ability isn't on the GCD.
As to a tool, AutoHotKey does have the ability to handle programming logic. It obviously can't hook into the WoW client and do something like "when I press 1, if art of war is up cast exorcism, otherwise cast divine storm" but you can have it do conditionals and other stuff. I really didn't do much more with it than have it do 1:1 broadcasting of certain keys in game, but I did have it set up to loop through a set of questions about which screen was the master, which was the slave, which was the healer, etc., so that it would send different keys to each client.
Connect With Us