If you just wanted this to work with windows, I'd suggest using win32api or ctypes (examples here: http://stackoverflow.com/a/1181539). But to be cross platform, the easiest way will be to use a package such as this one: https://github.com/PyUserInput/PyUserInput
Here's a link to one of PyUserInput's tests, it looks like it should easily be modified to do exactly what you're after:
Here's a link to one of PyUserInput's tests, it looks like it should easily be modified to do exactly what you're after:
https://github.com/PyUserInput/PyUserInp...sic.py#L21 Wrote:try: from pymouse import PyMouseEvent class event(PyMouseEvent): def move(self, x, y): print("Mouse moved to", x, y) def click(self, x, y, button, press): if press: print("Mouse pressed at", x, y, "with button", button) else: print("Mouse released at", x, y, "with button", button) e = event() #e.capture = True e.start() except ImportError: print("Mouse events are not yet supported on your platform")