Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 超时在NSAppleScript中无效_Objective C_Cocoa_Applescript_Applescript Objc - Fatal编程技术网

Objective c 超时在NSAppleScript中无效

Objective c 超时在NSAppleScript中无效,objective-c,cocoa,applescript,applescript-objc,Objective C,Cocoa,Applescript,Applescript Objc,我有一个简单的apple脚本,如下所示: tell application id "com.adobe.InDesign" set sel to selection end tell tell application id "com.adobe.InDesign" with timeout of 0.2 seconds set sel to selection end timeout end tell 此脚本执行正常,但当InDesign显示“保存确认

我有一个简单的apple脚本,如下所示:

tell application id "com.adobe.InDesign"
    set sel to selection
end tell
tell application id "com.adobe.InDesign"
    with timeout of 0.2 seconds
        set sel to selection
    end timeout
end tell
此脚本执行正常,但当InDesign显示“保存确认”对话框时,如果我执行脚本,它将等待2分钟(默认apple脚本超时)


保存确认对话框

因此,我指定超时如下:

tell application id "com.adobe.InDesign"
    set sel to selection
end tell
tell application id "com.adobe.InDesign"
    with timeout of 0.2 seconds
        set sel to selection
    end timeout
end tell
现在,如果我在AppleScript编辑器中执行上述脚本,一切都如我所料:

但是,当我通过NSAppleScript以编程方式执行同一脚本时,超时没有任何影响,程序会等待2分钟:

NSDictionary*errorDict;
NSString*脚本=
@“告诉应用程序id \“com.adobe.InDesign \”\n”
@“超时为0.2秒\n”
@“将sel设置为选择\n”
@“结束超时\n”
@“结束告诉\n”
;    
NSAppleScript*scr=[[NSAppleScript alloc]initWithSource:script];
[scr executeAndReturnError:&errorDict];
附加说明:
当我的cocoa代码正在执行时(当我的应用程序被阻止时),如果我在AppleScript Editor中执行相同的脚本,则我的cocoa代码将在2分钟超时前解除阻止。我的应用程序似乎在apple脚本超时行[?]
之前被阻止。我如何执行与AppleScript编辑器相同的apple脚本?
任何帮助都将不胜感激。

构建脚本并保存为应用程序应该可以解决此问题。它应该是相同的脚本,但只需在脚本的开头和结尾添加
on run
end run
。这样做的方法是,当你去保存,在保存菜单的底部,应该有一个文件格式下拉列表。选择“应用程序”选项并保存


我注意到这将使“默认Applescript超时”无效。

谢谢,我将尝试此解决方案,我如何在我的项目中使用“应用程序”?@mhtaqia您可以通过您的项目运行Applescript应用程序