There’s a reason they do this. They see a reflection of another bird in your window and since they have already “claimed” this area as their own, they are trying to attack this bird. It doesn’t matter how often they fly into your window or peck at it, they will continue doing so until you do something about it. There are some options: put wet newspapers on the outside of the window so they can’t see a reflection. Tie helium balloons near your window to scare away the birds. You can pull down the shades or close the drapes. Some people put tin foil pie pans near the windows to chase away the birds. You can buy these pans at the local dollar store. Or you can use some tin foil strips and dangle them at the windows. While the birds are nesting they are protective of their area, so once the eggs have hatched this pecking should stop. It can be very annoying since the noise can give you a headache. Most species of birds are protected, so you do need to be careful what you do. One other thing: pest control exterminators do not have a spray to get rid of the birds. There is nothing they can do beyond tell you what I have mentioned above.