If your dog barks or lunges at everyone who walks by the house or while you are walking, then these tips might help. Using a few training techniques to refocus your dog can help stop barking, nipping and lunging at other dogs and people.
If you are walking your dog and he starts staring at another dog or person, (which is supposedly, very rude behavior for a dog. My dog does it all the time.) put him in a sit position and stand directly in front of him so he can't see the dog. He'll try to look around your legs but move with his head and don't allow him to look. Keep feeding him treats, one after the other, to keep him focused on you until the other dog or person is out of his view. If your dog is clicker trained, use the clicker when he is focused on you.
I know this is hard to do if you are pressed for time while on the walk but it really does work. When I take my dog for a walk at a nearby park, I can actually get him to sit while other dogs walk by, then we continue on our way.
As far as barking from the window, that's a tough one. I'm still working on that with my dog but my dog behavior instructor says that it takes two weeks of calm behavior to break a dog's habit. Try putting something on the couch, so your dog can't see out the window for awhile. If he gets excited while on the
floor, distract him with treats and make him sit, basically the same thing as when you're on the walk.
Work Your Dog
Another thing you can do is practice commands when your dog gets overexcited. For instance, when you see him getting anxious while on a walk or in the house, have some treats ready and just have him sit, down, walk backwards, touch your hand, anything to keep him busy, so he knows you're in charge and have things under control.
Your dog might think he has to protect the house and the people he is walking with when you're outside. He has to learn that the situation is okay and you can take care of things. Hopes this helps.