Applescript droplet 没有 运行 另一个处理程序
Applescript droplet doesn't run another handler
我正在尝试使用以下代码在 Applescript 中制作一个 Droplet 脚本。
我有一个处理程序,它 运行 是一个带有所选文件的 POSIX 路径的命令行。
当我 运行 脚本一切正常时(我的命令行处理程序工作正常)。但是,如果我将文件放到我的脚本中,什么也不会发生。
我需要一些帮助,拜托
on run
set thePath to POSIX path of (choose file of type "img" default location (path to downloads folder from user domain))
doIt(thePath)
end run
on open myImageFile
tell application "Finder"
if (count of myImageFile) is greater than 1 then
display alert "A message" as critical
else if name extension of item 1 of myImageFile is not "img" then
display alert "A message" as critical
else
set thePath to POSIX path of item 1 of myImageFile
doIt(thePath)
end if
end tell
end open
将打开处理程序中的行:doIt(thePath)
更改为:my doIt(thePath)
.
错误的原因是您尝试在 finder 范围内使用您的处理程序,而 finder 没有将其视为自己的东西。所以必须在前面加上my
,这样handler才能解析。
我正在尝试使用以下代码在 Applescript 中制作一个 Droplet 脚本。
我有一个处理程序,它 运行 是一个带有所选文件的 POSIX 路径的命令行。
当我 运行 脚本一切正常时(我的命令行处理程序工作正常)。但是,如果我将文件放到我的脚本中,什么也不会发生。
我需要一些帮助,拜托
on run
set thePath to POSIX path of (choose file of type "img" default location (path to downloads folder from user domain))
doIt(thePath)
end run
on open myImageFile
tell application "Finder"
if (count of myImageFile) is greater than 1 then
display alert "A message" as critical
else if name extension of item 1 of myImageFile is not "img" then
display alert "A message" as critical
else
set thePath to POSIX path of item 1 of myImageFile
doIt(thePath)
end if
end tell
end open
将打开处理程序中的行:doIt(thePath)
更改为:my doIt(thePath)
.
错误的原因是您尝试在 finder 范围内使用您的处理程序,而 finder 没有将其视为自己的东西。所以必须在前面加上my
,这样handler才能解析。