What do you REALLY want it to do though? If you only need 1 or 2 commands then you might just want to make it into a macro and press the hotkey for that macro. For example:
Code:
/Select SOME GATHERABLE
/Attack
Pressing this macro would start gathering; you might need to set auto-approach in the options but it should actually move you to the gathering node and begin gathering it if you're within ~25m.
You could use SendInput but it flags keys as injected. SendInput actually is not that ugly of a way of performing the input, just risky. This method also might be slower (because each key needs to be pressed individually), and requires checking in case keystrokes were missed.
If you want to emulate key input without it being flagged as injected you might want to look into PostMessage; though if you think SendInput is bad then this will really be horrible for you.
A really dirty trick would be to inject the gatherable's entity offset into your target pointer... but I can't really say I'd recommend that either.
So, there are probably a lot of ways to do it, but why not just use a macro?