A recent post referenced the problem of not being able to stop firing unintentional unwanted shots at another target after killing a mob. It appears that this is some sort of game mechanic problem given the comments of players here and other sites.
No matter what the cause is, it can truly be a pain so I messed around this weekend to see if I could stop or at least control it.
If you've been experiencing this as I have the macros below seem to solve the problem. It worked well after a bit of practice getting used to the new keybind and timing it. You have to hit it fast to stop the unwanted shot.
If you don't use keybinds, drag the macro icon into one of your actionbar slots so you can mouse click it.
I play solo so I've only tested this by running a couple of 5 mans and on multiple mobs rounding em into a bunch of 3 or 4 to simulate enough confusion. One of the biggest problems with stopping the unwanted shot after the kill is losing your targetting-the macro solves that as well. You hit the macro without having to re-target or targetting the wrong mob. Then start your shot rotation and rinse and repeat.
You can also fire off a shot or two at a different mob in the group using whatever your target key is, then use the macro; stopping your attack while simultaneously switching back to the pet's target. Then commence your shot rotation without interruption.
A happy accident of this is you re-gain a wee bit of focus in the brief switch 
Macro:
/assist pet
/stopattack
This allows you stop the unwanted shot and maintain targetting to resume attacking quickly.
I also simulated it with:
/assist focus
/stopattack
This worked for me but my focus target is always my pet.
I do not know if the 'assist focus' macro will work in a raid situation. In theory it should but if you cause a wipe or get booted from the group it ain't on me-blame it on your pet.
Give it a try, do some testing and if you can improve it drop a comment.
P.S. Simply doing a keybind of stop attack in the UI works but you lose target and mobility.
Wouldn't hitting the ESC key be just as fast?
teoteodore said:
Wouldn't hitting the ESC key be just as fast?
To stop attack but you lose your targetting. Macro stops that and saves a lot of time trying to re-target, put up HM, start attacking again etc. Helpful with a whack of critters or dungeons. Give it a try.
not in game so I can't copy-paste, but I have one that I use that looks similar to yours and targets myself, dashes my pet back, and slaps on Mend Pet. I also have one that I use targetting my focus for multiple mobs in raid situation. You are right, they work great. Yes, escape works, but I like healing my pet.
Yours sounds cool. I have an all-in-one save my pets ass macro but I'll steal a piece of yours and add the call back as 'Here Boy" or "Hey Dummy, Run" haven't been working so well.
P.S. Love the closet. Could use more shoes.
There is an interface option (under the Combat heading) to stop your ranged autoattack when switching targets, but this mechanism was recently broken, at least for hunters - I'm not sure about other classes.
Turning the option on or off made little or no difference. The autoattack carried on from a deceased target to the next selected target, which in some cases could be (and was!) an as-yet unpulled mob at a 'safe' distance in the background. I noticed this on other hunters accompanying our parties as well as myself - we started getting all sorts of abuse (in pugs) and tellings-off from our tank (in guild parties) for bad pulls.
At first I thought I was just tired and playing badly, but after a while I began to realise that the mechanism had changed. Anyway, I gradually became used to compensating by various methods, including simply positioning myself so that no targetable background mobs were within hittable range.
But I'm fairly sure that this has been fixed now. At least, the problem seems to have just gone away, and it's only reading this post that reminded me of it.
Had to hunt for this thread because this just happened to me in Blackrock Caverns. Stop Auto Attack was checked (always is) and I pulled a mob right after we killed the last target. Understandably, the tank got irritated but I quickly apologized.
I figured out I was spamming an attack key and this caused me to auto target the nearest mob.
So… is there a way to deactivate auto targeting?
EDIT: Looks like Frostheim has us covered. Problem solved. Source.
Anj, you said you had Stop Auto Attack checked. Isn't that what Frosthiem suggested?
Frostheim seems to have it covered about as best as it can be for raids. From what he wrote it at least is on the UI side, not the players. I notice he says it helps somewhat.
This Didn't work with the tank as focus?
/assist focus
/stopattack
I could see that in a raid I suppose. Works fine for me but again there is only me and the pet. Intersting to know it doesn't work in a raid. Have you tried it?
Personally I think Blizz should just fix it. It's not like we're gaining an edge with it. Blizz is killing us with kindness.
The rest of the comments over there on the topic with macros etc seem too complex. Essentially what I suggested but with a whack of excess script binding to all shots and you'd still be needing a key or more. I don't have that many fingers or toes.
Agio, Stop Auto Attack probably does work during combat. But the problem I'm having is that point where I'm OOC: I accidentally press a key, I target a mob, and since I'm in range, the mob gets shot.
So I did this as Frostheim suggested:
/cast [@target, exists] <spell name>
where I don't accidentally shoot something unless I have it targeted first.
Yeah Anj I could see the macro not being efficient or practical in a raid situation. Too much goin on let alone having to remember to hit another key to avoid whacking another mob and even then it might fail if you're a millisecond too slow.
Frostheim's solution is about the best I think a person is going to find given it's using the UI and takes the onus off the player, which it shouldn't be on anyhow. Blizzard should really stop 'helping' us poor dumb hunters out 🙂
I noticed the "auto-target" thing happening to me, for the first time I can recall, in H:Lost City last night. Thankfully, it didn't cause any problems for the group (which was guildies anyway and it wouldn't have really mattered, lol) and I noticed it happening so I could be more aware of hitting that extra shot button when downing mobs. I think I'm gonna have to give the macro a try.
Oz-The one I created is for me and my selfish ways as I only solo.
Let me know if you try it or the one Anj posted. Just seems an enormous amount of scripting to add to every shot so would be nice if the simple one worked.
As I said in my intial posting of this it 'should' theoretically work in a group or raid-oy, I sound like Frostheim(who I love n respect like the child I never had) However I also said blame the pet if it causes a wipe 
We'll put The Lodge on the map for other things aside from all round coolness if the simple one works and buy Gar a condo in Libya with the proceeds 
Frosthiems answer seems to work for me. I dont pug much so could just be luck of the draw.