Window sensors, much like door sensors, work using a reed switch and a magnet. The reed switch attaches to your window frame, and the magnet attaches to the window itself. When a window with an active sensor is opened, the magnet pulls away from the reed switch and the alarm.
The reed switch typically needs to be within an inch of the magnet to work effectively. When set up correctly, a window sensor is an extremely reliable tool to monitor intrusion points throughout your home––so long as you change the batteries routinely.