Attack on condition?

Any way to stop extra pulls and only have macro attack if focus target is engaged with tank or something? Now If i extra click 1 time after Mob dies it might select target/focustarget and start attacking. Thx

Also why is most all hunter macro there is pet attacks when they are auto used?