Deep Terror Nami is correct about the definition of the use of macros and how unsportsman they are.
However, from what I understand about what you are wanting to accomplish, you may actually be making it more complicated than it needs to be.
If I understand you correctly, the action you are binding is already a default key.
These are the default keybindings
You will find "S" key is "Stop"
This will cancel all interruptable actions, and is commonly referred to as animation canceling.
While you have auto attack enabled and you have an enemy in range, your character should automatically attack the nearest target.
You can also do this by giving any action command beyond a certain point in an animation.
For example, all auto attacks have 3 parts of their animation.
The wind up, the damage/release, and the follow through.
The wind up phase is the moment you issue an attack (while within attack range), up to immediately before the damage/release phase. Issuing any other action command during this phase will cancel the auto attack completely. One notable exception to this is Kalista, who can not have her attack animation cancelled
Technically you can cancel the animation at any point within 0.1 seconds (time allotted intentionally by Riot designed to compensate for lag) before the damage is dealt for melee champions or the projectile is released by a ranged champion.
Cancelling the follow though phase is pretty much what you are doing here, and it actually can mechanically increase your attack speed.
This is particularly important to understand if you want to truly master Riven.
I would recommend that you seek out the YouTuber known as BoxBox.
They are very very good at this, and other tricks with Riven.