Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Avoiding the AESendMessage bug from 10.8.2 and, apparently, 10.9.0
+ (NSAppleEventDescriptor*)mm_appleEventWithEventClass:(AEEventClass)eventClass
eventID:(AEEventID)eventID
targetApplicationBundleID:(NSString*)bundleID
{
//NSAppleEventDescriptor *target = [NSAppleEventDescriptor descriptorWithDescriptorType:typeApplicationBundleID
// data:[bundleID dataUsingEncoding:NSUTF8StringEncoding]];
NSAppleEventDescriptor *target = [self mm_targetDescriptorForBundleID:bundleID];
return [NSAppleEventDescriptor appleEventWithEventClass:eventClass
eventID:eventID
targetDescriptor:target
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
}
+ (NSAppleEventDescriptor*)mm_targetDescriptorForBundleID:(NSString*)bundleID
{
NSRunningApplication* runningApplication = [[NSRunningApplication runningApplicationsWithBundleIdentifier:bundleID] lastObject];
pid_t pid = [runningApplication processIdentifier];
NSAppleEventDescriptor *target = [[[NSAppleEventDescriptor alloc] initWithDescriptorType:typeKernelProcessID bytes:&pid length:sizeof(pid)] autorelease];
return target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.