I can't be sure about your specific circumstances, but if you order a unit to attack something that's immune to your damage, the unit won't bother trying to fire. I don't think warp gates would be on that list though.
You're not using v- or x-moving, right? Naturally, giving orders to attack anything along the way to your target will cause great distraction.