Question

For an app I am working on I am using CGEventPost to post some key events and I noticed that it stopped working with sandboxing enabled, even I turned on the "Enable Access for Assistive Devices" system preference.

Is there an entitlement to allow the use of CGEventPost? Or, is there another way to post key events with apps submitted to the Mac App Store?

Was it helpful?

Solution

Can Mac App Store Sandboxed apps use CGEventPost?

No.

Is there an entitlement for CGEventPost? Or is there any way to post key events with apps submitted to the Mac App Store?

No.

If you look at the developer forums, Apple has made it very clear that they will never enable an entitlement for this, because it allows a blatantly obvious way for any app to escape the sandbox.

If you have some more specific need that you can justify (not "post some key events" but "get iPhoto do to XXX, which as far as I know can only be done by posting event YYY at it"), file a bug report, and post a thread on the dev forums.

This will do two things:

  1. Someone at Apple may suggest a workaround--possibly a private one that nobody else can tell you and/or one that isn't normally allowed on the App Store but will be accepted if you've been told to use it.
  2. It increases the chances that Apple will invent some better way to do what you want in the future.

OTHER TIPS

Old question, but accepted answer is wrong. There are apps in Mac App Store that are using CGEventPost to simulate events. For example apps "Remote Mouse" and "Mobile Mouse Server" do that. They can send input to any other app and based on symbols in those apps they are clearly using CGEventPost-function. I would like to know how are they doing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top