Louis is always looking out the window, and he barks at everyone he sees (not just people, squirrels too

.) How do I get him to stop barking? He is by no means aggressive. He will bark at our guests through the window, but when they come into our house he acts like they are his new friend. (He only barks at people when he is looking out the window, when we take a walk or go shopping he doesn't bark at anyone.) Does anyone else experience this?