Great idea, but its already been done (and works great I might add).
You're looking for
Zorlen's Hunter Functions
Example of the macros I use with Zorlen's addon installed (note all of these macros can also be found in QT UI, available on this site):
I setup my ranged attacks in ActionBar1 and my melee attacks in ActionBar2...then hide actionbar2 (easily done with BibMod).
This macro casts hunter's mark, and sends in your pet:
Code:
/script castMark();
/script PetAttack();
This macro casts auto shot, makes sure Aspect of the Hawk is up, and that ActionBar1 is active:
Code:
/cast Auto Shot
/script castHawk()
/script CURRENT_ACTIONBAR_PAGE=1;
/script ChangeActionBarPage();
This macro makes sure Aspect of the Hawk is up, and that Ranged keys (ActionBar1) are active:
Code:
/script castHawk()
/script CURRENT_ACTIONBAR_PAGE=1;
/script ChangeActionBarPage();
This macro casts Aspect of the Monkey, switches the main action bar to the melee bar, targets the nearest enemy, attacks it, and tells your pet to attack the target:
Code:
/script castMonkey()
/script CURRENT_ACTIONBAR_PAGE=2;
/script ChangeActionBarPage()
/script if (not Zorlen_canAttack()) then TargetNearestEnemy() end
/script AttackTarget()
/script PetAttack()
This macro just makes sure Aspect of the Monkey is up and that the melee bar is active:
Code:
/script castMonkey()
/script CURRENT_ACTIONBAR_PAGE=2;
/script ChangeActionBarPage()
Zorlen has examples fairly similar on his site, but the ones I listed above are the most handy in my opinion.
Good luck