Python 控制鼠标@MAC
Python 控制鼠标@MAC
#!/usr/bin/python
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
from time import sleep
class macMouse():
def mouseEvent(self,type, posx, posy):
theEvent = CGEventCreateMouseEvent(None,type,(posx,posy),kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(self,posx,posy):
self.mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(self,posx,posy):
self.mouseEvent(kCGEventLeftMouseDown, posx,posy);
self.mouseEvent(kCGEventLeftMouseUp, posx,posy);
mMouse = macMouse()
mMouse.mouseclick(650,170)
#for i in range(110):
# mMouse.mouseclick(650,170)
# sleep(0.1)
macmouse.py 查看 (1.01 KB)