Objective c 模拟鼠标按下事件时NSWindow冻结
收到鼠标按下事件后,myObjective c 模拟鼠标按下事件时NSWindow冻结,objective-c,mouseevent,nswindow,nsevent,cgeventtap,Objective C,Mouseevent,Nswindow,Nsevent,Cgeventtap,收到鼠标按下事件后,myNSWindow被冻结。我无法捕获挂在Xcode中的线程。我使用以下代码模拟鼠标事件: CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton); CGEventPost
NSWindow
被冻结。我无法捕获挂在Xcode中的线程。我使用以下代码模拟鼠标事件:
CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
如何解决此问题?我已将运行循环模式从NSDefaultRunLoopMode更改为NSRunLoopCommonModes,并且它可以工作。如果我在OS X默认应用程序上发送鼠标下/上事件,如系统首选项、磁盘实用程序等。在这里,它工作正常。这意味着我必须处理应用程序窗口中的任何内容?