Created
March 30, 2010 17:40
-
-
Save pepijndevos/349338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# implementation | |
from pymouse import PyMouseEventMeta | |
import systembridge | |
from threading import Thread | |
class PyMouseEvent(PyMouseEventMeta): | |
def __init__(self): | |
click_tap = systembridge.get_event_tap(mousepress | mouserelease) | |
move_tap = systembridge.get_event_tap(mousemove) | |
t = Thread(target=self.run, args=(click_tap, self.click)) | |
t.start() | |
t = Thread(target=self.run, args=(move_tap, self.move)) | |
t.start() | |
def run(self, tap, callback): | |
while True: | |
event = tap.next_event() | |
if(event.type == 'move') | |
(event.x, event.y) = callback(event.x, event.y) | |
else: | |
(event.x, event.y, event.button) = callback(event.x, event.y, event.button) | |
event.process() | |
# user code | |
from PyMouse import PyMouseEvent | |
class handler(PyMouseEvent): | |
def click(self, x, y, button): | |
print "there was a click at", x, y, "with this button:", button | |
# there was a click at 123 456 with this button: 1 | |
return x, y, button | |
def move(self, x, y): | |
print "the mouse was moved to", x, y | |
return x, y | |
test = handler() # start listening | |
del test # stop listening |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment