刚开始使用Apple脚本并寻求帮助..我正在尝试使用Apple脚本创建一个IF语句,但似乎无法让它工作。
计划是发送imessage并附加文件,如果脚本是用指定的文件执行的,如果没有,只需发送文本。
例如:
仅限文字示例: imessage 5555555555“hi”“NoAttachment”
文字+文件示例: imessage 5555555555“hi”“/ location / test.jpg”
这是我正在使用的脚本: https://gist.github.com/aktau/8958054
但是在底部发生了以下变化:
on run {targetBuddyPhone, targetMessage, targetFile}
tell application "Messages"
-- if Messages.app was not running, launch it
set wasRunning to true
if it is not running then
set wasRunning to false
launch
close window 1
my waitUntilRunning("Messages", 1)
close window 1
end if
-- send the message
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
set targetFileSend to targetFile
if targetFileSend = "NoAttachment" then
send targetMessage to targetBuddy
else
send POSIX targetFileSend to targetBuddy
send targetMessage to targetBuddy
end if
-- if the app was not running, close the window
if not wasRunning
close window 1
end if
end tell
end run
当我执行脚本时,我得到: 1635:1649:语法错误:预期的行尾但找到了标识符。 (-2741)
我在这里做错了什么?而不是使用触发器“NoAttachment”,使用nullvalue会更好吗?
非常感谢任何帮助!
答案 0 :(得分:0)
这完成了这项工作:
send POSIX file targetFileSend to targetBuddy