你没有展示你当前是如何复制和粘贴的。虽然这应该是可以使用以下类似的方式来完成:
tell application "Word"
set theData to (the clipboard as text)
set the clipboard to theData
end tell
echo -n
无法工作是因为AppleScript的 do shell script
命令使用的是sh,而不是bash,而sh的echo是内置的,不接受选项。明确指定/bin/echo即可解决问题:
do shell script "/bin/echo -n " & quoted form of my_string & " | pbcopy"
将剪贴板设置为已定义的标准附加项。您不需要将其包含在 tell application "Word" ... 中。
set the clipboard to (the clipboard as text)