I've heard about replacing the trigger with a switch. Replacing the spring with an electro magnet seems doable. I don't think the batteries would fit on or in the gun. A second option would be to have electromagnetic pistons on a self pumping PCP. Let me know how it turns out
Problem is that magnetic fields loses strength with the square of distance.Say at 0 distance you have a force of 1, at one inch you will have a force of 0.5 and at a distance of 2 inches you will have a force of 0.25 and at 4 inches you will have a force of 0.125.So the system loses power very quickly compared to a spring.And imagine all the aluminium you would have to use as not to interfere with the magnetic fields.If you want to see what a dedicated inventor can do using electricity as propulsion then google "rail gun"But thats a total loss system and uses huge amounts of power.