【发布时间】:2011-10-04 07:16:49
【问题描述】:
我编写了一个 AppleScript,旨在在 TextExpander 注意到击键时触发。从 AppleScript 编辑器运行时它工作正常,但在某些情况下从 TextExpander 运行时它也会发出哔哔声。
这是脚本:
tell front window of application "BBEdit"
if (length of selection) is not 0 then
add prefix and suffix of selection prefix "[" suffix "]"
else
set text of selection to "["
end if
end tell
当我输入 [ 字符时它被设置为触发,其想法是如果选择文本,它会将文本包装在 [ 和 ] 但是如果没有选择任何文本,那么它应该像往常一样简单地键入 [ 字符。
无论运行如何,它都能完美运行,但如果从 TextExpander 和 运行,“else”路径会跟随 (set text of selection to "[") 系统发出哔哔声。我不确定 BBEdit 或 TextExpander 是否正在生成哔声,但如果我完全删除“else”部分或者它运行时选择了文本(“if”路径),则不会发出哔声。
【问题讨论】:
标签: applescript bbedit