They are not related. Worn window motors tend to fail once the motor heats up. Try raising and lowering your window repeatedly and see if its fails. Once it stops- it will start to work again once the limiter resets itself over a few minutes. YOu'll need to replace the window motor.
As far the the "check engine light". This is only related to failures that will affect emissions. With that, it could be due to many many reasons. You'lll need a scan tool to see what code was detected. 4 cylinders tent to have AF ratio sensor failures, and EGR low flow codes. Good luck!
Certified Toyota Technician