刚刚开始在这里使用苹果脚本并寻求一些帮助..我试着用苹果脚本创建一个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“相比,使用空值会更好吗?
任何帮助都是非常感谢的!
发布于 2017-06-29 10:42:51
这就完成了工作:
send POSIX file targetFileSend to targetBuddyhttps://stackoverflow.com/questions/44792864
复制相似问题