首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apple Script / imessage

Apple Script / imessage
EN

Stack Overflow用户
提问于 2017-06-28 10:51:33
回答 1查看 1K关注 0票数 0

刚刚开始在这里使用苹果脚本并寻求一些帮助..我试着用苹果脚本创建一个IF语句,但似乎不能让它工作。

我们的计划是发送一个imessage并附加一个文件,如果脚本是使用指定的文件执行的,如果不是,只发送文本。

例如:

纯文本示例: imessage 5555555555 "hi“"NoAttachment”

文本+文件示例: imessage 5555555555 "hi“"/location/test.jpg”

这是我正在使用的脚本:https://gist.github.com/aktau/8958054

但在底部做了以下更改:

代码语言:javascript
复制
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“相比,使用空值会更好吗?

任何帮助都是非常感谢的!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-29 10:42:51

这就完成了工作:

代码语言:javascript
复制
send POSIX file targetFileSend to targetBuddy
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44792864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档