def generatemouseevent(self, x, y, eventType="<STR_LIT>",<EOL>drag_button_override='<STR_LIT>'):
if drag_button_override not in mouse_click_override:<EOL><INDENT>raise ValueError('<STR_LIT>' %drag_button_override)<EOL><DEDENT>global drag_button_remembered<EOL>point = (x, y)<EOL>button = centre  <EOL>click_type = None<EOL>if eventType == "<STR_LIT>" or eventType == "<STR_LIT>":<EOL><INDENT>if drag_button_override is not '<STR_LIT>':<EOL><INDENT>events = [mouse_click_override[drag_button_override]]<EOL><DEDENT>elif drag_button_remembered:<EOL><INDENT>events = [drag_button_remembered]<EOL><DEDENT>else:<EOL><INDENT>events = [move]<EOL><DEDENT>if eventType == "<STR_LIT>":<EOL><INDENT>point = CGEventGetLocation(CGEventCreate(None))<EOL>point.x += x<EOL>point.y += y<EOL><DEDENT><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_left]<EOL>drag_button_remembered = drag_left<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [release_left]<EOL>drag_button_remembered = None<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_left, release_left]<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_left, release_left]<EOL>click_type = double_click<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_other]<EOL>drag_button_remembered = drag_other<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [release_other]<EOL>drag_button_remembered = None<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_other, release_other]<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_other, release_other]<EOL>click_type = double_click<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_right]<EOL>drag_button_remembered = drag_right<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [release_right]<EOL>drag_button_remembered = None<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_right, release_right]<EOL><DEDENT>elif eventType == "<STR_LIT>":<EOL><INDENT>events = [press_right, release_right]<EOL>click_type = double_click<EOL><DEDENT>else:<EOL><INDENT>raise LdtpServerException(u"<STR_LIT>" % eventType)<EOL><DEDENT>for event in events:<EOL><INDENT>CG_event = CGEventCreateMouseEvent(None, event, point, button)<EOL>if click_type:<EOL><INDENT>CGEventSetIntegerValueField(<EOL>CG_event, kCGMouseEventClickState, click_type)<EOL><DEDENT>CGEventPost(kCGHIDEventTap, CG_event)<EOL>time.sleep(<NUM_LIT>)<EOL><DEDENT>return <NUM_LIT:1><EOL>
Generate mouse event on x, y co-ordinates.

@param x: X co-ordinate
@type x: int
@param y: Y co-ordinate
@type y: int
@param eventType: Mouse click type
@type eventType: str
@param drag_button_override: Any drag_xxx value
        Only relevant for movements, i.e. |type| = "abs" or "rel"
        Quartz is not fully compatible with windows, so for drags
        the drag button must be explicitly defined. generatemouseevent
        will remember the last button pressed by default, and drag
        that button, use this argument to override that.
@type drag_button_override: str

@return: 1 on success.
@rtype: integer