0

I need to send keystrokes from Today Extension App, so I wrote like this.

    CGEventSourceRef source =     CGEventSourceCreate(kCGEventSourceStateHIDSystemState);

    CGEventRef f4 = CGEventCreateKeyboardEvent(source, kVK_F4, true);
    CGEventSetFlags(f4, kCGEventFlagMaskControl);
    CGEventTapLocation location = kCGHIDEventTap;

    CGEventPost(location, f4);

    CFRelease(f4);
    CFRelease(source);`


and I wrote 'com.apple.systemevents' in the .entitlements file.

<?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.temporary-exception.apple-events</key>
    <array>
        <string>com.apple.systemevents</string>
    </array>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
</dict>
</plist>

But, It didn't work.
Please tell me how to do this.
Thanks.

Tsuzu
  • 63
  • 1
  • 5

1 Answers1

1

the exception you ask or is for apple events as in apple script events

you don't generate that but you want to directly induce key / mouse presses

that won't work. no sandboxed app / extension can generate these kinds of events system wide

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135