Prevent carpenter ants by eliminating excess or standing moisture in your home. Ants need moisture and are attracted to sweating appliances or bathroom fixtures. Any plumbing leaks should also be found and repaired. For high moisture areas of the home, try using a dehumidifier.
Store firewood away from your home, and take care to knock it free of any winged ants before introducing it into the home. Only a winged female that has mated is capable of starting a colony. Bringing in worker ants or winged males on firewood poses no threat to your home, according to Michigan State University.
Clear brush, deadwood and weeds away from the foundation of the house. Doing so will prevent nests of carpenter ants being established in close proximity, and later infiltrating your home. Satellite nests are a problem in homes when there is a primary nest nearby. Satellite nests are like storage buildings for the ants, and do not require a queen to be present outside of the home nest.
Treat existing colonies with a licensed insecticide. There are many types available, and should be chosen according to where the nest is located. The only way to eliminate a colony is to kill the queen, and dusts and baits work more effectively for this task. For killing the winged ants in your window, a common aerosol insecticide works well.