Almost all methods of generating electricity depend on using some other form of energy to spin an electrical generator.
If the other form of energy is kinetic energy robbed from wind, then the wind turns the blades of a big 'fan', and the blades spin the electrical generator.
In a commercial windmill, the electrical generator is in that 'box' on top of the pole, right behind the hub of the blades.