It you accidentally broke the lock on one of your windows, don't panic; you can probably just change it. Unfortunately, window locks are pretty easy to break or paint over if you aren't careful. Having a broken window lock not only means that your house is less safe from thieves, but also that your window is probably no longer sealed. If you are heating or cooling your home, you could be throwing money out that broken window!
Begin by removing your old window lock. In all likelihood, if you have ever painted your window frame, this step is going to require some paint thinner. Your old window lock should be affixed to your window frame with tiny screws. If you painted over the screws, you aren't going to be able to get them right out with a screwdriver. Try to clean some of that paint out with a rag soaked in paint thinner. Depending upon how long that paint has been on those screws, this may or may not work. You may have to supplement your cleaning efforts with some muscle. Go ahead and try to chip out a little bit of that paint with an X-acto knife, especially if it's painted on there pretty thick. Don't be shy because you're probably going to have to do some touch up painting after you get that old lock out anyhow.
Once the old lock is out, repaint your window frame. Painting before you actually add the new lock will prevent you from painting the new lock shut. Allow the new paint to dry overnight.
The type of new lock you install will depend upon whether your window opens out like a door, or whether it slides up and down. Either way, you are going to have one piece that you attach to the wall and one that you attach to the frame on the window. Both should be attached directly in the center of either the bottom or side of your window. Close the window to attach your new lock so that it lines up properly. Attach the female part of the lock to the house and the male part of the lock to the window with tiny screws.