I want to be able to simulate mouse clicks, moves, and drags within my own app. I can do that using CGEventPost
, but that requires accessibility permission, which seems silly to require when I'm not trying to control another app. An alternative is to create mouse NSEvent
s and use -[NSApplication postEvent:atStart:]
. By that approach, I am able to click a button and watch it highlight and unhighlight, but the mouse cursor never moves and the pressedMouseButtons
class property of NSEvent
never changes. Is there a better way to simulate mouse events without requiring accessibility permission?