especially if you use autocast.
No, you just don't set it to autocast.
I'm sorry, but you can't just say "OK, this magnetic field isn't going to effect friendly units!" You
could equip your fighters to trigger a magnetic field of their own, but that would only result in them being thrust
away from the ship at a great, and probably deadly, velocity.
RL,
I can not debate magnetism with you since I am not a physicist. I would be surprised if the effects of this magnetism weapon would be absolutely impossible to effectively counter. However since this is a game and not real life and the game is played by mostly non physicists I
can say that this weapon does not have an effect on friendly units. There I said it.

It would not detract from the game at all for me if the developers made it so, but then maybe the game is played mainly by scientists and if it would completely spoil the game for them I would gladly defer.
Since the game has space lanes between planets, it can have a magnetic field weapon that only effects enemy fighters if it makes for a better game. Having a weapon that targets your own forces seems coounter intuitive and the ai does not appear to know the best times to use its ship's special abilities. If it is possible to improve this system, I won't say fix it I would vote for that regardless of how physics is perceived in the real world.