Assuming this is the driver's door switch... Do the windows work regardless if the driver door is open or shut, using a different door's switch?
The driver door has a rubber gasket that wires run through from the engine compartment to the door which includes power for the window switch/motor, keyless entry pad, power mirrors, etc. Check the wires inside this rubber gasket, guarentee you there are some wires snapped from pressure.
When you open the door the snapped wires may touch and make a connection, when you close it they will separate and you will lose power to certain electronics in the driver door