Windows open a half inch resolves a "door ajar" issue? That's a strange one, unless the window being open allows air to "push" against the door.
Read this thread on the subject:
Door Chime / Dome Light / Door Ajar Problem - Ford Ranger Forum
If the door switches turn out to be functional (good), then read about half way down this post; could be that one of the doors wiring is grounding, as the door switches are N/O (normally open), so when the door is opened, the switch becomes closed, completing a ground circuit. If this wire is chaffed somewhere along its route to the GEM module (behind the radio) that triggers the door ajar light to come on. However, 2004 and newer Rangers don't have this GEM module but rather a SJB:
Door Ajar light will not go off.