Need assistance.

I need a macro command that spams mend pet and misdirection. I’ve tried autohotkey mend pet but it spams too quickly or too slowly and won’t work then with glyph of misdirection my macro has misdirect but with the glyph refreshing the CD when used on a pet it spams misdirect on it so I need a wait macro for MD to where it won’t spam on pets and I need a macro for mendpet to where it’ll actually work while spamming my other macros, thank you. Preferably a wait macro for mendpet as well since spamming it is useless.