You could probably use CGEventCreate
to create a gesture event. The event types "officially" defined for CGEventCreate
don't include gesture event types, but you could pass in the values defined in NSEvent.h
:
NSEventTypeGesture
NSEventTypeMagnify
NSEventTypeSwipe
NSEventTypeRotate
NSEventTypeBeginGesture
NSEventTypeEndGesture
The values for non-gesture types seem to map directly to the kCGEvent<TYPE>
values in CGEventTypes.h
so it's reasonable to expect the gesture event types will work:
CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
CGEventRef event = CGEventCreate(eventSource);
CGEventSetType(event, NSEventTypeMagnify);
//continue to set up the event
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…