I could have been the solenoid, but I would suspect it to be a bad commutator. If the lights are bright, and you can hear a click the solenoid is usually working and the method of impacting the starter moves the armature just a few thousands of an inch which is all it takes to make contact again and the starter works. If it is a bad commutator, a more effective technique is to impact lightly on the starter motor housing itself, and either replace the commutator or the entire starter motor for the fix.