Well, as far as I know, you'd make a macro in game, which included your script.
You're trying to click button 1, button 2, button 3, button 4 then button 5 with this script.
You could just as easily create your macro, to be a castsequence which will then:
Cast spell 1, cast spell 2, cast spell 3, cast spell 4, cast spell 5.
It's very easy to accomplish this via the /castsequence macro
/castsequence spell 1, spell 2, spell 3.
You can include optional resets in the sequence.
Combat resets when you exit combat, Target resets when you acquire a new target, a numerical value resets when that many seconds have passed or a modifier key resets when the button is pressed with a modifier.
And you can have multiple modifiers in the macro.
/castsequence reset=30/combat/target/alt Corruption, Agony, Siphon Life, Immolate, Shadow Bolt, Shadow Bolt, Shadow Bolt, Shadow Bolt, Shadow Bolt
This will reset to the beginning of the sequence 30 seconds after the first button is pressed, no matter where you are in the sequence.
It also resets to the beginning if you click it while the alt key is pressed, or if combat ends or if you change targets.
If you wanted multiple sequences, you can easily name them.
Sequence one might be called DOT.
Sequence two might be called NUKE.
Sequence three might be called AOE.
You can easily create another macro, which can have mouse modifiers.
I'm not sure of all the modifiers, or even if my syntax is correct (wow macro/ui forum has the syntax in Cogwheel's thread) but it could look something like this:
/click [left action button] DOT
/click [right action button] NUKE
A macro can call another macro by name. So if you really wanted to, you could create the macro which will call your macro'd cast sequences.
You don't even need to put the cast sequences on an action bar, if a macro is calling them by name.
If you do put them on a bar, you can go into keybindings in WoW, and assign a binding to that bar slot.
So if your AoE macro was (warlock example).. Demonform, Immolate Aura, Charge, Seed, Seed, Seed, Seed, Seed, Seed, Seed, you could put this in Right Action Bar 1, Button 3.... and then go into the keybindings and change the keybind to say your mouses thumb button.
I don't think this is exactly what you're looking for, but it gets you exactly what you asked for in a different way.
Connect With Us