debugging 如何使用AppleScript调试快捷批处理

3phpmpom  于 2023-01-13  发布在  其他
关注(0)|答案(3)|浏览(85)

只需3行脚本就可以在不离开applescript编辑器的情况下测试droplet应用程序

set fich to POSIX file "/Appli/conv2spct.app" as string

 tell application "Finder" to open POSIX file "/Users/yourusername/Desktop/somefile" using application file fich

如果快捷批处理中有错误,脚本编辑器applescript将打开一个显示对话框

cwtwac6a

cwtwac6a1#

为2个元素选择文件的相同脚本

set fileappli to POSIX path choose file of type {"APPL"} with prompt "Choose a Droplet application to debug"--the droplet for debug

set fileargument to POSIX path choose file --the file argument to pass at droplet 

tell application "Finder" to open fileargument using application file fileappli

如果快捷批处理中有错误,脚本编辑器applescript将打开一个显示对话框

vjrehmav

vjrehmav2#

下面是使用do shell script的实用替代方法,它可能允许您指定 * 多个 * 文件参数:

do shell script "open -a /Appli/conv2spct.app ~/Desktop/somefile1 ~/Desktop/somefile2"

上面的路径碰巧不需要在shell中用引号引起来(转义),但是当使用变量指定文件路径时,最好使用quoted form of(要传递多个参数,请将quoted form of应用于 each):

do shell script "open -a " & quoted form of fileappli & " " & quoted form of fileargument
wmvff8tz

wmvff8tz3#

看起来自从第一次提出这个问题以来,这个问题变得更简单了。根据这个documentation,你可以写:

open {choose file}
on open theDroppedItems
  ...
end open

从AppleScript编辑器中运行此命令,您选择的文件将被打开,就像它被拖放到编译的脚本上一样。

相关问题