Beispiel #1
0
    def open(self):
        print '[!] New connection.'

        ourEvent = CGEventCreate(None)
        currentpos = CGEventGetLocation(ourEvent)

        # Send current mouse position and screen res to client.
        self.write_message(
            str(currentpos.x) + "|" + str(currentpos.y) + "|" +
            str(mainMonitor.size.width) + "|" + str(mainMonitor.size.height))
Beispiel #2
0
def getMouseLoc():
    mouseEvent = CGEventCreate(NULL)
    mouseLoc = CGEventGetLocation(mouseEvent)
    return mouseLoc
Beispiel #3
0
 def getCursorPosition(self):
     point = CGEventGetLocation(CGEventCreate(None))
     return point
Beispiel #4
0
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 Quartz.CoreGraphics import CGEventCreate
from Quartz.CoreGraphics import CGEventGetLocation

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):
        mouseEvent(kCGEventLeftMouseDown, posx,posy);
        mouseEvent(kCGEventLeftMouseUp, posx,posy);

while True:
  time.sleep(5)
  print "move mouse"
  ourEvent = CGEventCreate(None);
  pos=CGEventGetLocation(ourEvent);
  print str(pos.x)+" "+str(pos.y)
  mousemove(pos.x -1, pos.y -1)
  mousemove(pos.x+1,pos.y+1)
  mousemove(pos.x,pos.y)

Beispiel #5
0
def cur_pos():
    return CGEventGetLocation(CGEventCreate(None))
Beispiel #6
0
def mousePos():
    event = CGEventCreate(None)
    pointer = CGEventGetLocation(event)
    #CFRelease(event)
    return pointer.x, pointer.y