CGEventCreateKeyboardEvent and Sandboxes

I'm trying to do this piece of code to send keystrokes to a finder in a sandboxed application for Mac OS X:

    CGEventRef a = CGEventCreateKeyboardEvent(NULL, keycode, true);
    CGEventSetFlags(a, kCGEventFlagMaskControl);
    CGEventPost(kCGHIDEventTap, a);
    CFRelease(a);

      

It works in a non-sanboxed environment, but it doesn't work when it is isolated, also if I use this right:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
     <dict>
       <key>com.apple.security.app-sandbox</key>
       <true/>
       <key>com.apple.security.temporary-exception.apple-events</key>
       <array>
       <string>com.apple.systemevents</string>
       </array>
     </dict>
  </plist>

      

I found someone suggested to use Apple Scripts instead, it works but it is very slow and not suitable for my needs.

Is there a chance?

+3
objective-c xcode cocoa macos


source to share


No one has answered this question yet

Check out similar questions:

6
Is AudioFilePlayer audio sandbox compatible?
3
understanding the difference between CGPostKeyboardEvent and CGEventCreateKeyboardEvent
2
Using OSX Security Bookmarks in Firemonkey App
2
CGEventCreateKeyboardEvent and CGEventTapLocation
1
CGEventCreateKeyboardEvent flags?
0
2 versions (sandbox or not), 1 app - Optimal approach
0
Sandbox for Mac with Snow Leopard
0
Simulate keystrokes in a sandbox
0
Problems with CGEventRef and CGEventCreateKeyboardEvent
0
Corrupt iPhone app name



All Articles
Loading...
X
Show
Funny
Dev
Pics