Have auto target macro that needs tweaking

Ok so ive been getting back into my holy pally again, i have her aligned with necro lords so it gives her the Vanquishers hammer Skill.

i have used my old rogue macro for the base of it, so it goes like this…

/console targetNearestDistance 2.000000
/targetenemy [noharm][dead]
/console targetNearestDistance 5.000000
/cast [harm,nodead] Vanquisher’s Hammer(Necrolord)

it does its job of auto picking the nearest target and casting hammer so i can use word of glory buff it gets from using hammer.

but what im trying to do is get it to auto switch back to the previous friendly i had targeted so i dont have to reclick their name-bar or portrait cause once i use the above macro it will target said enemy and have to manually switch back to my friendly target.

it also only shows the cooldown of the skill if i have an enemy target picked, id tried messing with /showtooltip “skill” but nothing works.

any help would be great thank you.

Maybe something like this will work for you?

#showtooltip
/console targetNearestDistance 2.000000
/targetenemy [noharm][dead]
/console targetNearestDistance 5.000000
/stopmacro [noharm][dead]
/cast Vanquisher’s Hammer(Necrolord)
/targetlasttarget [harm]

I don’t know why #showtooltip wouldn’t work, but you can put a /stopmacro before an unconditional Vanquisher’s Hammer, and that should cause it to always show the cooldown, and stop the macro if the target was not successfully switched. And the /targetlasttarget should cause it to switch back, only if you’re targeting a enemy.

Why not just @targettarget the spell?

#showtooltip
/cast [harm] [@targettarget,harm,nodead] [] Vanquisher's Hammer