def run(self): #inspired by this guide on python automation https://automatetheboringstuff.com/chapter18/ try: PyMouseEvent.run(self) except KeyboardInterrupt: self._writeCoordinateList()