How can I simulate "command+tab" with mouse middle button?

I like to use mouse button(I have a 5 buttons mouse) to switch applicatons. I want to use middle button to simulate “command+tab”, this macro will be:

  1. When I hold the middle button, the macro will type command+tab and hold command key

  2. I use my mouse pointing to an application and I released middle button, the macro will release the command key as well.

I can use this with steermouse, steermouse has an application switch feature, but it used the default one. Keyboard maestro has a more powerful application switcher, How can write macro simulationg this behavior?