Experimentally, CGRequestPostEventAccess is not synchronous. Even if it has opened an alert offering to take the user to System Settings to grant access, it returns NO in a millisecond or so.
I was also confused by the fact that the related function CGPreflightPostEventAccess just seems to report the access that the process had when it launched, even if the access shown in System Settings changed while the process was running.
That was beginning to make me believe that changes in trust while a process is running don't affect the process at all, but that seems not to be the case: If an agent is initially trusted to post events, and installs an event tap, but trust is revoked while it's running, then the Mac becomes mostly unresponsive to keyboard events.
I've submitted FB11832484 requesting documentation on these APIs.
Note that the framework prevents you from requesting multiple times.
I'm guessing you mean that repeated calls to CGRequestPostEventAccess will silently fail, but please let me know if there is some other form of "prevention".
Topic:
Accessibility & Inclusion
SubTopic:
General
Tags: