I suppose you could wire it up to a relay, get a battery source up there so that it will have power after the ignition switch is off. The main problem is going to be telling the sunroof when it is closed. Else the motor will just keep on running till it is in vent and the clutch kicks in. I might have to play with that some this weekend.
The other option would be find an older style ASI series moon roof, and pull the whole electronics system out of it and retrofit it to your sunroof. That would be a MAJOR undertaking, which at the very least would require you to remove the whole sunroof assembly, and cut holes in the tracks to mount magnets...