macOS: simulated mouse event only works when launching binary, not application bundle
问题 I have the following code which moves the mouse cursor on a Mac: void moveCursorPos() { CGPoint ppos; ppos.x = 100; ppos.y = 100; CGEventRef e = CGEventCreateMouseEvent(nullptr, kCGEventMouseMoved, ppos, kCGMouseButtonLeft); CGEventPost(kCGHIDEventTap, e); CFRelease(e); } It works when I run my software directly from its binary - e.g. ./foo.app/Contents/MacOS/foo . It does not not work when I start it through open foo.app . Doing open ./foo.app/Contents/MacOS/foo works. The first time I