This is how to activate app using AppleScript.
In Instrument, leak happend at "NSAppleEventDescriptor listDescriptor = [returnDescriptor coerceToDescriptorType:typeAEList];"
---- src below ----
NSString command = [NSString stringWithFormat:
@"try\n"
@"tell application "%@"\n"
@"activate\n"
@"delay 0.5\n"
@"tell application "System Events" to tell process "%@"\n"
@"tell (first window whose subrole is "AXStandardWindow")\n"
@"set fullScreen to value of attribute "AXFullScreen"\n"
@"if fullScreen = true then\n"
@"set value of attribute "AXFullScreen" to false\n"
@"end if\n"
@"end tell\n"
@"end tell\n"
@"end tell\n"
@"tell application "System Events"\n"
@"tell process "%@"\n"
@"tell window %d\n"
@"set {position, size} to {{%d,%d},{%d,%d}}\n"
@"end tell\n"
@"end tell\n"
@"end tell\n"
@"on error errMsg number errorNumber\n"
@"return "Error with number: " & errorNumber as text\n"
@"end try", ownerName, ownerName, ownerName, idx, (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height];
NSDictionary errorDict;
NSAppleEventDescriptor returnDescriptor = NULL;
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:command];
if( scriptObject == nil )
return false;
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
NSAppleEventDescriptor *listDescriptor = [returnDescriptor coerceToDescriptorType:typeAEList];
NSString *result = @"";
for (NSInteger i=1; i<=[listDescriptor numberOfItems]; ++i) {
NSAppleEventDescriptor *stringDescriptor = [listDescriptor descriptorAtIndex:i];
if ( stringDescriptor.stringValue == nil ) continue;
result = [NSString stringWithFormat:@"%@%@", result, stringDescriptor.stringValue];
}
BRs,
YM