Is this Macro Possible?

I am wondering if anyone knows a way I can make a macro to set focus to another players pet if they have one out?
Such as a warlock in group has a voidwalker out, is there a quick macro that will auto set focus on it quickly for me?

I’m not sure if you can make a macro to do target specific players pets anymore outside of a keybind to Target Party Pets in the interface panel

You can make target/focus pets, you just can’t macro target/focus a warlock’s pet over a hunter’s pet

For example,

/clearfocus
/focus partypet1

If party 1 (a friendly character in your party – whoever that might be) has a pet, this will set the focus to that person’s pet.

/clearfocus
/focus partypet1
/focus [noexists] partypet2
/focus [noexists] partypet3
/focus [noexists] partypet4
/focus [noexists] partypet5

I’m not sure you can focus enemy pets. This might work for arenas. Probably won’t.

/clearfocus
/focus arenapet1
/focus [noexists] arenapet2
/focus [noexists] arenapet3

targetpet might work but otherwise no way to iterate through enemy pets in a bg.

For more info

https://wow.gamepedia.com/UnitId
https://wow.gamepedia.com/Macro_commands
https://wow.gamepedia.com/Macro_conditionals

this wasnt for enemy pets. Was just for group, but are you saying this should work to focus a locks pet if there is not hunter pet out or this will only work for hunter pets?

it will work for any pet. Mage, Lock, Hunter, …

cool beans, thank you

one more question. Is there a way to make it so it doesn’t matter what the persons party position is?

Could optimize to:

/clearfocus
/focus [@partypet1,exists] [@partypet2,exists] [@partypet3,exists] [@partypet4,exists] [@partypet5,exists]

etc.

excellent, thank you