How to highlight multiple targets with some boxes?

I want to highlight targets (enemies) shown on screen with boxes when I want to throw some skill to them, like this
question

I want it can be applied to all targets shown on screen, but not to those hided (or occluded) behind some buildings.

How do I implement it?