The leading-and-trailing-edge detection means 8 is disposed at the front end of the guide rail 2 and when the weather strip 1 prevents thelight from reaching the photosensor, the weather strip 1 is detected as being on the guide rail 2, and vice versa.The control unit 9 consists of a computer system including a CPU, RAMs, etc.