cgeventtap

Performing a double click using CGEventCreateMouseEvent()

我与影子孤独终老i 提交于 2019-11-26 19:38:05
问题 I'm using the following code to simulate a click of the mouse: void PostMouseEvent(CGMouseButton button, CGEventType type, const CGPoint point) { CGEventRef theEvent = CGEventCreateMouseEvent(NULL, type, point, button); CGEventSetType(theEvent, type); CGEventPost(kCGHIDEventTap, theEvent); CFRelease(theEvent); } void LeftClick(const CGPoint point) { PostMouseEvent(kCGMouseButtonLeft, kCGEventMouseMoved, point); NSLog(@"Click!"); PostMouseEvent(kCGMouseButtonLeft, kCGEventLeftMouseDown, point)

How do you use CGEventTapCreate in Swift?

橙三吉。 提交于 2019-11-26 16:10:04
问题 Has anyone managed to get this function to work in Swift? Here is a reference SO post from last year: Using CGEventTapCreate Trouble with parameters in Swift Apple Doc: https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Reference/QuartzEventServicesRef/index.html#//apple_ref/c/func/CGEventTapCreate Here is how the CGEventTapCallBack is defined: typealias CGEventTapCallBack = CFunctionPointer<((CGEventTapProxy, CGEventType, CGEvent!, UnsafeMutablePointer<Void>) ->