It is tedious to see that you do not even know the existence of a unit event so useful.
It is more tedious to see that you do not even take a look at the trigger editor to see if such a thing exists.
And on top of that, it is even more tedious to see that I have to make a Target Detection System...
So here it is TDS:
(Be aware that this system is only detecting auto-acquires of units. Aka, units that are idle and then notice a target in range to attack it.)