I have a simple apple script as follows:
tell application id "com.adobe.InDesign"
set sel to selection
end tell
This script is executed fine, but when the InDesign displaying Save Confirm Dialog, if I execute the script, It waits for 2 minutes (Default apple script timeout).
Save Confirm Dialog
Thus I specified timeout as follows:
tell application id "com.adobe.InDesign"
with timeout of 0.2 seconds
set sel to selection
end timeout
end tell
Now If I execute above script in AppleScript Editor every thing is as I expected:
But when I execute same script programmatically by NSAppleScript the timeout has no effects and the program waits for 2 minutes:
NSDictionary *errorDict;
NSString *script =
@"tell application id \"com.adobe.InDesign\"\n"
@" with timeout of 0.2 second\n"
@" set sel to selection\n"
@" end timeout\n"
@"end tell\n"
;
NSAppleScript* scr = [[NSAppleScript alloc] initWithSource: script];
[scr executeAndReturnError: &errorDict];
Additional description:
When my cocoa code is executing (when my app is blocked) If I execute same script in AppleScript Editor then my cocoa code is unblocked before 2 minutes timeout. It seems my app is blocked before apple script timeout line [?]
How can I execute apple script same as AppleScript Editor?
Any help would be appreciated.