Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # python MacMouseRobot.py
- # http://pythonhosted.org/pyobjc/install.html
- import time
- from Quartz.CoreGraphics import CGEventCreateMouseEvent
- from Quartz.CoreGraphics import CGEventPost
- from Quartz.CoreGraphics import kCGEventMouseMoved
- from Quartz.CoreGraphics import kCGEventLeftMouseDown
- from Quartz.CoreGraphics import kCGEventLeftMouseDown
- from Quartz.CoreGraphics import kCGEventLeftMouseUp
- from Quartz.CoreGraphics import kCGMouseButtonLeft
- from Quartz.CoreGraphics import kCGHIDEventTap
- def mouseEvent(type, posx, posy):
- theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
- CGEventPost(kCGHIDEventTap, theEvent)
- def mousemove(posx,posy):
- mouseEvent(kCGEventMouseMoved, posx,posy);
- def mouseclick(posx,posy):
- #uncomment this line if you want to force the mouse to MOVE to the click location first (i found it was not necesary).
- #mouseEvent(kCGEventMouseMoved, posx,posy);
- mouseEvent(kCGEventLeftMouseDown, posx,posy);
- mouseEvent(kCGEventLeftMouseUp, posx,posy);
- print("Mac Mouse")
- mouseclick(0,0);
- mousemove(100,100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement