MD Macro help

I am looking for a macro that casts MD on my focus target, and if there is no focus target, the macro will target my pet.
The macro below does not work; if I have no focus target, it lights up my cursor to select a target instead of casting on my pet.

#showtooltip Misdirection
/cast [help][@focus,nodead,help][@pet,exists] Misdirection

What is the real macro, experts?

#showtooltip Misdirection
/cast [@focus,nodead][@pet,exists]Misdirection

This should work just fine.

Slight tweak:

#showtooltip
/use [help][@focus,help,nodead][@pet,pet]Misdirection

This uses it on a friendly target you manually select first, as well as prevents it from trying to use Misdirection on an enemy focus target.

I also tend to use [@pet,pet] over [@pet,exists] as it saves a few characters, which helps in bigger macros.

If you want one you can drop in to any macro ahead of another ability, Ghorak’s macro (with the #showtooltip line removed) works great for that.

True, I more-or-less never utilize the focus frame for enemy targets so did not think to include that part.

This one actually works as intended.
Any idea why all the other ones people suggest wouldn’t work? :o

If your macro was exactly as entered above, it’s because you had Misdirection on a separate line. Each command (#showtooltip, /cast, /use, /equip, /dismount, etc) should go be one line starting with the command and ending with the spell/item/etc (where applicable). There are a few exceptions (#showtooltip will display the specified spell, or if you don’t specify, it will display whatever spell is going to cast or ? if no conditions are true.)

Check this guide Macros: Essential Information for a full rundown of macros, how they work, how to use them, and what they can/can’t do.

all the other ones just lit up my cursor as to select a target for MD