While allowing us to feel close to the outside world, windows cause heat to escape from buildings in winter and let the Sun's unwanted rays enter in summer.
This has sparked a quest for "smart" windows that can adapt to weather conditions outside.
Today's smart windows are limited to regulating light and heat from the sun, allowing a lot of potential energy to escape, study co-author Yanfeng Gao of the Chinese Academy of Sciences told AFP.
"The main innovation of this work is that it developed a concept smart window device for simultaneous generation and saving of energy."
Engineers have long battled to incorporate energy-generating solar cells into window panes without affecting their transparency.
Gao's team discovered that a material called vanadium oxide (VO2) can be used as a transparent coating to regulate infrared radiation from the Sun.
VO2 changes its properties based on temperature. Below a certain level it is insulating and lets through infrared light, while at another temperature it becomes reflective.
A window in which VO2 was used could regulate the amount of Sun energy entering a building, but also scatter light to solar cells the team had placed around their glass panels, where it was used to generate energy with which to light a lamp, for example.
"This smart window combines energy-saving and generation in one device, and offers potential to intelligently regulate and utilise solar radiation in an efficient manner," the study authors wrote in the journal Nature Scientific Reports.