OK, well I had the same problem in my '96 Mégane RT. It's fixed now after around an hour's work, following the advice above- thanks for the pics fig_jam_uk!!!
Here's how it went...
Removing the fixtures was harder than expected since the directional light did not want to be budged! There's a metal spring which was wrongly positioned, so the unit would not slip out as it should. We worked around this by sliding the key-detector piece (see the pics above) towards the windscreen so it came off, then removing two star screws, and taking the whole unit off the roof. It was hanging from wires, but pretty secure.
So then we got onto the tricky bit- the motor. We decided to leave the sunroof in a closed position, then match the motor's 'memory' to that. With the motor engaged (i.e. none of the three screws removed) we closed the sunroof completely, checking it was flush on the outside. You can tell the sunroof is fully closed because the back end raises to a high point- it will drop away from this high point just before it slides or tilts- watch closely.
We then loosened the screws, and dropped the motor away from the gear system (you can feel a discernable 'clunk' as this happens), and were free to run the motor without it affecting the sunroof. As expected, at around 70% of its full range, the motor stopped itself (thinking the sunroof was shut). So now the sunroof was shut, and the motor 'thought' it was shut, which was all good.
Here however, we made a mistake - d'oh! By hand
, we pushed the motor back into place, and tested our work. It all went well until the gearing partially slipped, and we managed to make the problem worse by getting both sides of the sun-roof out of sync! Oh dear
You see, the one gear from the motor slips in between two linear tracks. As the motor turns, one is forced off to the left, and one is forced off to the right, and thus both sides of the windscreen are moved in unison. It took a lot of pushing and pulling on the windscreen, and jabbing the tracks with a screwdriver before we got them back in sync with each other, since a rectangle trying to slide diagonally in a slot is never going to work! So here's a warning: MAKE SURE THE GEARING IS PROPERLY ENGAGED AND ALL THREE SCREWS ARE LOCATED AND TIGHTENED BEFORE YOU ATTEMPT TO USE THE MOTOR AGAIN. As you push the motor back into place, you should feel the 'clunk' again, as the gear locates itself.
But anyway, after all this it now works fine and since it's coming up to summer, I'm happy! If you have the tools I'd recommend having a go, but just be wary of the above problem.