2017-06-28 58 views
0

剛開始蘋果腳本這裏尋找一些幫助..我試圖創建一個使用蘋果腳本IF語句只是不能似乎得到它的工作。蘋果腳本/即時聊天

該計劃是發送即時聊天,如果腳本與指定的文件執行,如果沒有,只是發送文本附加文件。

例如:

僅文本示例: 即時聊天5555555555 「喜」, 「NoAttachment」

文字+文件示例: 即時聊天5555555555 「喜」, 「/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

嘗試添加字... 「文件」 「POSIX」 後\t'發送POSIX文件targetFileSend到targetBuddy' – wch1zpink

回答

0

該做的工作:

send POSIX file targetFileSend to targetBuddy