Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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
Path Applescript中的错误-10004和错误-10000是什么_Path_Applescript_Error Code_Osascript - Fatal编程技术网

Path Applescript中的错误-10004和错误-10000是什么

Path Applescript中的错误-10004和错误-10000是什么,path,applescript,error-code,osascript,Path,Applescript,Error Code,Osascript,我的电脑上有一个Applescript,但我同事的电脑上没有。我在操作路径时遇到两个错误:-10004和-10000。我有一个关于如何解决这个问题的想法,但首先我想了解这些错误代码 以下是脚本(我删除了无用部分,完整版本已打开): 以下是日志: tell application "OmniGraffle Professional 5" get window 1 --> window id 5032 get document of window id 5032

我的电脑上有一个Applescript,但我同事的电脑上没有。我在操作路径时遇到两个错误:
-10004
-10000
。我有一个关于如何解决这个问题的想法,但首先我想了解这些错误代码

以下是脚本(我删除了无用部分,完整版本已打开):

以下是日志:

tell application "OmniGraffle Professional 5"
   get window 1
       --> window id 5032
   get document of window id 5032
       --> document "MSD.graffle"
   get name of document "MSD.graffle"
       --> "MSD.graffle"
   offset of "." in "MSD.graffle"
       --> error number -10004
end tell
tell current application
   offset of "." in "MSD.graffle"
       --> 4
end tell
tell application "OmniGraffle Professional 5"
   choose folder with prompt "Pick the destination folder"
       --> alias "Macintosh HD:Users:Romain:Desktop:Temp:"
   display alert "The file already exists. Do you want to replace it?" buttons {"Cancel", "Erase"} cancel button 1
       --> {button returned:"Erase"}
   do shell script "rm -rf '/Users/Romain/Desktop/Temp/MSD/'"
       --> error number -10004
end tell
tell current application
   do shell script "rm -rf '/Users/Romain/Desktop/Temp/MSD/'"
       --> ""
end tell
tell application "OmniGraffle Professional 5"
...
...
   save document "MSD.graffle" in "Macintosh HD:Users:Romain:Desktop:Temp:MSD:1- Navigation - 1Layout.png"
       --> error number -10000
Result:
error "OmniGraffle Professional 5 got an error: AppleEvent handler failed." number -10000
谢谢


我更新了脚本,但仍然出现错误
-10000
。以下是修改后的行:

save theDocument in file exportFilename


我还没有发现这些错误代码记录在哪里,但它们主要处理目标应用程序无法处理的事件。前两个错误-10004是由于在应用程序tell语句中使用了标准添加命令(offsetdo shell script)-应用程序不知道这些命令是什么,将错误向上传递到AppleScript,但AppleScript知道它们是什么并执行了它


我没有OmniGraffle,但最后一个错误是告诉您无法执行save命令,可能是由于目标不是文件说明符的问题-它只是一个文本字符串,因此您可能必须将其强制为命令所需的内容

错误-10000--10015是事件注册表错误

错误-10000本身并不是目标错误,因为在这些情况下,它通常会抛出一个-1708。大多数情况下,这不是目标错误,而是命令不完整或括号使用错误。如果您使用:

save theDocument in file export_filename
错误-10004是一个特权冲突错误,这意味着您正在对文件执行不允许的操作。可能不允许删除该文件,而do shell脚本命令应始终在应用程序块之外使用。问题是,目标应用程序可以作为脚本以外的其他用户运行。我并不是说这是错误,但有可能这就是问题所在。否则,您就没有足够的权限,需要向用户请求管理员权限

do shell script "do something" with administrator privileges.

谢谢你的回答!我用我使用的新脚本更新了我的问题,它给了我相同的错误(-10000)。谢谢!我强制作为一个文件,但它不工作。它确实在我的计算机上工作。它可能需要别名或POSIX路径-您需要检查脚本字典,以查看它对save命令的要求。我无法强制将其作为别名,因为该文件不存在,即使脚本字典告诉我它需要别名(它来自标准套件)。
save theDocument in file export_filename
do shell script "do something" with administrator privileges.