Example #1
0
 def mouseRightClick(self):
     cursor = self.getCursorPosition()
     time.sleep(0.100)
     CGEventPost(
         kCGHIDEventTap,
         CGEventCreateMouseEvent(None, kCGEventRightMouseDown,
                                 (cursor.x, cursor.y), kCGMouseButtonRight))
     CGEventPost(
         kCGHIDEventTap,
         CGEventCreateMouseEvent(None, kCGEventRightMouseUp,
                                 (cursor.x, cursor.y), kCGMouseButtonRight))
Example #2
0
 def mouseLeftClick(self):
     cursor = self.getCursorPosition()
     time.sleep(0.0001)
     CGEventPost(
         kCGHIDEventTap,
         CGEventCreateMouseEvent(None, kCGEventLeftMouseDown,
                                 (cursor.x, cursor.y), kCGMouseButtonLeft))
     CGEventPost(
         kCGHIDEventTap,
         CGEventCreateMouseEvent(None, kCGEventLeftMouseUp,
                                 (cursor.x, cursor.y), kCGMouseButtonLeft))
     time.sleep(0.0001)
Example #3
0
def mouseEvent(type, posx, posy):
        theEvent = CGEventCreateMouseEvent(
                    None, 
                    type, 
                    (posx,posy), 
                    kCGMouseButtonLeft)
        CGEventPost(kCGHIDEventTap, theEvent)
Example #4
0
def _createMouseEvent(source, posX, posY):
    '''
    Creates a moust event and adds it to the queue to be processed.
    '''
    event = CGEventCreateMouseEvent(None, source, (posX, posY),
                                    kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, event)
Example #5
0
def doubleClick(posx, posy, clickCount):
    theEvent = CGEventCreateMouseEvent(None, kCGEventLeftMouseDown,
                                       (posx, posy), kCGMouseButtonLeft)
    CGEventSetIntegerValueField(theEvent, kCGMouseEventClickState, clickCount)
    CGEventPost(kCGHIDEventTap, theEvent)
    CGEventSetType(theEvent, kCGEventLeftMouseUp)
    CGEventPost(kCGHIDEventTap, theEvent)
    CGEventSetType(theEvent, kCGEventLeftMouseDown)
    CGEventPost(kCGHIDEventTap, theEvent)
    CGEventSetType(theEvent, kCGEventLeftMouseUp)
    CGEventPost(kCGHIDEventTap, theEvent)
Example #6
0
def mouseEvent(type, *args):
    if len(args) == 2:
        posx, posy = args
    elif len(args) == 1 and isinstance(args[0], Point):
        posx, posy = args[0]
    else:
        raise Exception('Error! Invalid arguments for mouseEvent')

    CGEventPost(
        kCGHIDEventTap,
        CGEventCreateMouseEvent(None, type, (posx, posy), kCGMouseButtonLeft))
    time.sleep(0.01)
Example #7
0
def mouseEvent(type, posx, posy):
    surgeon_process = filter(lambda x: x, [
        x if x.get('NSApplicationName') == 'Surgeon Simulator 2013' else None
        for x in NSWorkspace.sharedWorkspace().launchedApplications()
    ])[0]
    #surgeon_process = filter(lambda x: x, [x if x.get('NSApplicationName') == 'Steam' else None for x in  NSWorkspace.sharedWorkspace().launchedApplications()])[0]
    high_psn = surgeon_process.get('NSApplicationProcessSerialNumberHigh')
    low_psn = surgeon_process.get('NSApplicationProcessSerialNumberLow')
    surgeon_psn = (high_psn, low_psn)

    #surgeon_psn = (low_psn, high_psn)
    #print(surgeon_process)
    #print(surgeon_psn)
    # maybe change the first param "source"
    # Maybe get rid of the mousebuttonleft
    theEvent = CGEventCreateMouseEvent(None, type, (posx, posy),
                                       kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, theEvent)
Example #8
0
def mouseEvent(eventVal, mouseLocation=False):
    if (mouseLocation == False): mouseLocation = getMouseLoc()
    return CGEventCreateMouseEvent(PYMAC_SOURCE_REF, eventVal, mouseLocation,
                                   0)
Example #9
0
def movemouse(x, y):
        theEvent = CGEventCreateMouseEvent(None, kCGEventMouseMoved, (x,y), kCGMouseButtonLeft)
        CGEventPost(kCGHIDEventTap, theEvent)
Example #10
0
def m_event(type, x, y, button=kCGMouseButtonLeft):
    event = CGEventCreateMouseEvent(None, type, (x, y), button)
    CGEventPost(kCGHIDEventTap, event)
Example #11
0
def set_position(x, y):
    event = CGEventCreateMouseEvent(None, kCGEventMouseMoved, (x, y),
                                    kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, event)
Example #12
0
File: maca.py Project: half0wl/maca
def _mouse_event(type, x, y):
    event = CGEventCreateMouseEvent(None, type, (x, y), kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, event)
Example #13
0
 def moveMouseTo(self, x, y):
     return CGEventPost(
         kCGHIDEventTap,
         CGEventCreateMouseEvent(None, kCGEventMouseMoved,
                                 CGPointMake(x, y), kCGMouseButtonLeft))
Example #14
0
 def mouseEvent(self, type, posx, posy):
     '''create a mouse event and post'''
     theEvent = CGEventCreateMouseEvent(None, type, (posx, posy), kCGMouseButtonLeft)
     CGEventPost(kCGHIDEventTap, theEvent)